Added /fly command and adjusted sleep requirement.#335
Added /fly command and adjusted sleep requirement.#335junerhobart wants to merge 10 commits intooddlama:mainfrom
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.
I'm not sure if changing this default value is a good idea.
| 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.
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.
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.
This should be configurable
There was a problem hiding this comment.
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.
This hard-coded message should be translatable
There was a problem hiding this comment.
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.
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.
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.
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.
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.
This hard-coded message should be translatable
There was a problem hiding this comment.
This file seems quite old but idk if we should delete it
There was a problem hiding this comment.
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.
These sentences does not have points at the end.
docs/index.html
Outdated
| <blockquote> | ||
| <p>Why can't I build anything?</p> | ||
| </blockquote> | ||
| "</blockquote> |
| 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.
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.
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.
| // Configuration | ||
| @ConfigDouble( | ||
| def = 0.5, | ||
| def = 0.2, |
vane-regions/src/main/java/org/oddlama/vane/regions/RegionFlyManager.java
Outdated
Show resolved
Hide resolved
vane-regions/src/main/java/org/oddlama/vane/regions/RegionFlyManager.java
Outdated
Show resolved
Hide resolved
- revert sleep threshold default back to 0.5 - restore org.json relocation in build.gradle.kts - import HashSet directly instead of fully-qualified - fall damage protection now always applies, not just when high up - simplify fall damage check using remove() - use StringUtils.removeStart instead of substring - drop /vane reload from graylist docs, just restart - fix missing leading slash on perm add commands in graylist - move flight in regions docs to regions.md source file
Sylfare
left a comment
There was a problem hiding this comment.
Other lang files are not updated yet
|
|
||
| ### Quick start | ||
|
|
||
| - Enable in `vane-admin` config: set `world_protection.enabled: true`, then restart the server. |
There was a problem hiding this comment.
Does /vane reload works here, or do you really have to restart the server?
docs/index.html
Outdated
| <div id="body-feature-vane-bedtime--night_to_day" class="hidden"> | ||
| <div class="p-5 border border-b-0 border-gray-200 dark:border-gray-700 dark:bg-gray-900"> | ||
| <div class="prose prose-slate prose-img:rounded-xl prose-img:w-1/3 prose-img:sm:m-4 prose-img:w-full prose-img:sm:w-1/2 prose-img:lg:w-2/5 prose-img:min-w-32 prose-img:max-w-full prose-img:float-right prose-img:clear-right prose-h1:clear-right prose-h2:clear-right prose-img:float-right dark:prose-invert max-w-none"><p>Once at least 50% of all players in the world are asleep, the night is skipped with a smooth transition to the next day.</p></div> | ||
| <div class="prose prose-slate prose-img:rounded-xl prose-img:w-1/3 prose-img:sm:m-4 prose-img:w-full prose-img:sm:w-1/2 prose-img:lg:w-2/5 prose-img:min-w-32 prose-img:max-w-full prose-img:float-right prose-img:clear-right prose-h1:clear-right prose-h2:clear-right prose-img:float-right dark:prose-invert max-w-none"><p>Once at least 20% of all players in the world are asleep, the night is skipped with a smooth transition to the next day.</p></div> |
There was a problem hiding this comment.
The limit is back to 50%, you should regenerate the docs
| if (region == null) { | ||
| return false; | ||
| } |
There was a problem hiding this comment.
I have a doubt about this: does it allows players who can fly with some other ways, like Essentials' /fly command?
| if (!(event.getEntity() instanceof Player)) { | ||
| return; | ||
| } | ||
|
|
||
| // Only handle fall damage | ||
| if (event.getCause() != EntityDamageEvent.DamageCause.FALL) { | ||
| return; | ||
| } | ||
|
|
||
| final var player = (Player) event.getEntity(); |
There was a problem hiding this comment.
You can avoid the cast on L211 by adding the variable name after instanceof
if (!(event.getEntity() instanceof Player player)) {
return;
}
// Only handle fall damage
if (event.getCause() != EntityDamageEvent.DamageCause.FALL) {
return;
}
final var player_id = player.getUniqueId();| shadowJar { | ||
| configurations = listOf() | ||
| relocate("org.json", "org.oddlama.vane.external.json") | ||
| } |
There was a problem hiding this comment.
I don't know enough about shadowing, but I'm not sure this is a good idea to remove it
- fix bedtime docs still showing 20% instead of 50% - restore org.json relocation in vane-trifles - use instanceof pattern matching in fall damage handler - don't manage flight for players who already have it from elsewhere (Essentials etc) - add fly/visualize lang keys to all non-English lang files, bump to version 4
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%.