-
-
Notifications
You must be signed in to change notification settings - Fork 47
Added /fly command and adjusted sleep requirement. #335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
### Changes - Added `/fly` command Players can now fly within their own region or any region where they have build permissions. - Adjusted bedtime percentage Reduced required sleep percentage from **50%** to **20%**.
Updated the webpage to reflect my previous changes being /fly in regions and 50% sleep requirement to 20%
|
If you have any questions please contact me at "@junologist" on discord |
| // Configuration | ||
| @ConfigDouble( | ||
| def = 0.5, | ||
| def = 0.2, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if changing this default value is a good idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, please remove that change
| private static final long FALL_DAMAGE_PROTECTION_MS = 15000; // 15 seconds | ||
|
|
||
| // Track players who manually disabled flight via /fly (opt-out of auto-fly) | ||
| private java.util.HashSet<UUID> manual_fly_opt_out = new java.util.HashSet<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can directly import HashSet
| if (event.getFrom().getBlockX() == event.getTo().getBlockX() && | ||
| event.getFrom().getBlockY() == event.getTo().getBlockY() && | ||
| event.getFrom().getBlockZ() == event.getTo().getBlockZ()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idk if event.getFrom.equals(event.getTo()) works here?
|
|
||
| // Track players who are protected from fall damage after leaving a region | ||
| private Map<UUID, Long> fall_damage_protected = new HashMap<>(); | ||
| private static final long FALL_DAMAGE_PROTECTION_MS = 15000; // 15 seconds |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be configurable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will make sure to add that
| final var region = get_module().region_at(player.getLocation()); | ||
|
|
||
| if (region == null) { | ||
| player.sendMessage("§cYou must be inside a region to use this command."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This hard-coded message should be translatable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot about that that might take a while for all of them
| get_module().fly_manager.set_manual_opt_out(player.getUniqueId(), true); | ||
| // Stop visualizing the region | ||
| get_module().stop_visualizing_region(player.getUniqueId()); | ||
| player.sendMessage("§aFlight disabled."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This hard-coded message should be translatable
| get_module().fly_manager.set_manual_opt_out(player.getUniqueId(), false); | ||
| // Start visualizing the region | ||
| get_module().start_visualizing_region(player.getUniqueId(), region); | ||
| player.sendMessage("§aFlight enabled."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This hard-coded message should be translatable
|
|
||
| if (get_module().is_visualizing_region(player_id)) { | ||
| get_module().stop_visualizing_region(player_id); | ||
| player.sendMessage("§cRegion visualization disabled."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This hard-coded message should be translatable
| } else { | ||
| final var region = get_module().region_at(player.getLocation()); | ||
| if (region == null) { | ||
| player.sendMessage("§cYou must be inside a region to visualize it."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This hard-coded message should be translatable
| } | ||
|
|
||
| get_module().start_visualizing_region(player_id, region); | ||
| player.sendMessage("§aVisualizing region boundaries. Use §b/region visualize§a again to disable."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This hard-coded message should be translatable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file seems quite old but idk if we should delete it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It definitely is old. But you are right, if we decide to delete it, it probably shouldn't be in this PR. So let's keep it for now.
docs/index.html
Outdated
| <li>Upon entering a region where you have permissions, flight is automatically enabled—just double-jump to start flying</li> | ||
| <li>Use <code>/fly</code> to manually toggle flight on/off with visual feedback</li> | ||
| <li>Particle visualization shows region boundaries while flying, automatically updating when moving between regions</li> | ||
| <li>Fall damage protection is provided when exiting a region while airborne</li> | ||
| <li>Flight automatically disables when leaving the region or entering an area without permissions</li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These sentences does not have points at the end.
docs/index.html
Outdated
| <blockquote> | ||
| <p>Why can't I build anything?</p> | ||
| </blockquote> | ||
| "</blockquote> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trailing quote
| final var region = get_module().all_regions().stream() | ||
| .filter(r -> r.id().equals(region_id)) | ||
| .findFirst() | ||
| .orElse(null); | ||
|
|
||
| if (region != null) { | ||
| // Mark as actively flying | ||
| flying_players.put(player_id, region_id); | ||
| // Start visualizing the region | ||
| get_module().start_visualizing_region(player_id, region); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ifPresent could be used here
get_module().all_regions().stream()
.filter(r -> r.id().equals(region_id))
.findFirst()
.ifPresent(region -> {
// Mark as actively flying
flying_players.put(player_id, region_id);
// Start visualizing the region
get_module().start_visualizing_region(player_id, region);
});There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It definitely is old. But you are right, if we decide to delete it, it probably shouldn't be in this PR. So let's keep it for now.
| <li>Admins of the region can change the portal settings</li> | ||
| <li>The visibility of the portal can be restricted to either players that have the portal permission or other portals that are in a region with the same region group.</li> | ||
| </ul> | ||
| <h2>Flight in Regions</h2> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is autogenerated, so any new text should be added in documentation/content/vane-regions/regions.md instead. When regenerating the documentation this will automatically create the html.
|
|
||
| ### Quick start | ||
|
|
||
| - Enable in `vane-admin` config: set `world_protection.enabled: true`, then run `/vane reload`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's only state the configuration that must be changed, and not mention /vane reload in this context. I don't want to proliferate any usage of server or plugin config reload (even though the vane-internal command should do the right thing most of the time). Since server reloads are always the reason for subtle bugs in many plugins I think it is better to always recommend restarting the server.
| - Grant a newcomer build rights with `perm add <player> user`. | ||
| - Or allow trusted members to vouch: give them `verified` via `perm add <player> verified`, then they can `/vouch <other_player>`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make this consistent and always use a leading / for commands? I see it has mixed usage here.
| // Configuration | ||
| @ConfigDouble( | ||
| def = 0.5, | ||
| def = 0.2, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, please remove that change
| } | ||
| relocate("org.bstats", "org.oddlama.vane.external.bstats") | ||
| relocate("org.reflections", "org.oddlama.vane.external.reflections") | ||
| relocate("org.json", "org.oddlama.vane.external.json") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whats the reason for these changes? Is org.json included in the server nowadays? Otherwise we do need that.
| // Visualize existing regions | ||
| for (final var visualize_owner : region_visualizations.keySet()) { | ||
| final var region = region_visualizations.get(visualize_owner); | ||
| if (region == null) { | ||
| continue; | ||
| } | ||
|
|
||
| // Get player for visualization | ||
| final var offline_player = getServer().getOfflinePlayer(visualize_owner); | ||
| if (!offline_player.isOnline()) { | ||
| continue; | ||
| } | ||
| final var player = offline_player.getPlayer(); | ||
|
|
||
| // Get the region extent | ||
| final var extent = region.extent(); | ||
| final var world = getServer().getWorld(extent.world()); | ||
| if (world == null) { | ||
| continue; | ||
| } | ||
|
|
||
| final var min = extent.min(); | ||
| final var max = extent.max(); | ||
|
|
||
| // Corners | ||
| final var A = new BlockPos(min.getX(), min.getY(), min.getZ()); | ||
| final var B = new BlockPos(max.getX(), min.getY(), min.getZ()); | ||
| final var C = new BlockPos(max.getX(), max.getY(), min.getZ()); | ||
| final var D = new BlockPos(min.getX(), max.getY(), min.getZ()); | ||
| final var E = new BlockPos(min.getX(), min.getY(), max.getZ()); | ||
| final var F = new BlockPos(max.getX(), min.getY(), max.getZ()); | ||
| final var G = new BlockPos(max.getX(), max.getY(), max.getZ()); | ||
| final var H = new BlockPos(min.getX(), max.getY(), max.getZ()); | ||
|
|
||
| // Visualize each edge - always valid (green) and local to player | ||
| visualize_edge(world, A, B, true, player); | ||
| visualize_edge(world, B, C, true, player); | ||
| visualize_edge(world, C, D, true, player); | ||
| visualize_edge(world, D, A, true, player); | ||
| visualize_edge(world, E, F, true, player); | ||
| visualize_edge(world, F, G, true, player); | ||
| visualize_edge(world, G, H, true, player); | ||
| visualize_edge(world, H, E, true, player); | ||
| visualize_edge(world, A, E, true, player); | ||
| visualize_edge(world, B, F, true, player); | ||
| visualize_edge(world, C, G, true, player); | ||
| visualize_edge(world, D, H, true, player); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it should be part of a separate PR about region visualization
| .getKeys() | ||
| .stream() | ||
| .filter(key -> key.toString().startsWith(storage_region_prefix)) | ||
| .map(key -> StringUtils.removeStart(key.toString(), storage_region_prefix)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why change this? Looks equivalent
| final var player_id = player.getUniqueId(); | ||
|
|
||
| // Check if player is protected from fall damage | ||
| final var protection_time = fall_damage_protected.get(player_id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use .remove which returns the object, if any. Then the code below will be a lot shorter :)
| get_module().stop_visualizing_region(player_id); | ||
|
|
||
| // If they're high in the air, protect them from fall damage | ||
| if (high_in_air) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we always want to protect them from fall damage? Seems akward that falling from 9 blocks will hurt but falling from 11 wont
Changes
Added
/flycommand Players can now fly within their own region or any region where they have build permissions.Adjusted bedtime percentage Reduced required sleep percentage from 50% to 20%.