From 7744d3dce0a6e297de2d97c864923184b8383110 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Out?= <38955258+bjorn-out@users.noreply.github.com> Date: Sat, 2 May 2026 16:59:17 +0200 Subject: [PATCH 1/3] Improve safe teleportation location finding --- .../realty/command/util/SafeLocationFinder.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/realty-paper/src/main/java/io/github/md5sha256/realty/command/util/SafeLocationFinder.java b/realty-paper/src/main/java/io/github/md5sha256/realty/command/util/SafeLocationFinder.java index 6c95e28..8756864 100644 --- a/realty-paper/src/main/java/io/github/md5sha256/realty/command/util/SafeLocationFinder.java +++ b/realty-paper/src/main/java/io/github/md5sha256/realty/command/util/SafeLocationFinder.java @@ -228,9 +228,16 @@ private static boolean defaultIsSafe(@NotNull Block feetBlock) { BlockVector3 max = region.getMaximumPoint(); int startX = (min.x() + max.x()) / 2; - int startY = (min.y() + max.y()) / 2; + int startY; int startZ = (min.z() + max.z()) / 2; + // Start searching around ground level for tall plots + if (max.y() - min.y() >= 100 && 80 <= max.y() && 80 >= min.y()) { + startY = 80; + } else { + startY = (min.y() + max.y()) / 2; + } + // Load center chunk and check center first return world.getChunkAtAsync(Math.floorDiv(startX, 16), Math.floorDiv(startZ, 16)) .thenCompose(chunk -> { From 3a219d6d4765277745782c2f49f1fe28bd4b55b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Out?= <38955258+bjorn-out@users.noreply.github.com> Date: Sun, 17 May 2026 22:18:41 +0000 Subject: [PATCH 2/3] Make starting Y-level configurable --- .../src/main/java/io/github/md5sha256/realty/Realty.java | 2 +- .../github/md5sha256/realty/command/TeleportCommand.java | 5 ++++- .../realty/command/util/SafeLocationFinder.java | 9 +++++---- .../io/github/md5sha256/realty/settings/Settings.java | 6 +++++- realty-paper/src/main/resources/settings.yml | 5 ++++- 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/realty-paper/src/main/java/io/github/md5sha256/realty/Realty.java b/realty-paper/src/main/java/io/github/md5sha256/realty/Realty.java index 7ed2ca9..dbd9739 100644 --- a/realty-paper/src/main/java/io/github/md5sha256/realty/Realty.java +++ b/realty-paper/src/main/java/io/github/md5sha256/realty/Realty.java @@ -541,7 +541,7 @@ private void registerCommands( }, messageContainer), new RemoveCommand(messageContainer), new SignCommand(paperApi, executorState, messageContainer), - new TeleportCommand(getLogger(), paperApi, messageContainer, safeLocationFinder), + new TeleportCommand(getLogger(), paperApi, this.settings, messageContainer, safeLocationFinder), new SubregionCommandGroup(paperApi, this.settings, messageContainer), new CleanupCommandGroup(this.database, executorState, diff --git a/realty-paper/src/main/java/io/github/md5sha256/realty/command/TeleportCommand.java b/realty-paper/src/main/java/io/github/md5sha256/realty/command/TeleportCommand.java index cc3067d..523f623 100644 --- a/realty-paper/src/main/java/io/github/md5sha256/realty/command/TeleportCommand.java +++ b/realty-paper/src/main/java/io/github/md5sha256/realty/command/TeleportCommand.java @@ -10,6 +10,7 @@ import io.github.md5sha256.realty.database.entity.RealtySignEntity; import io.github.md5sha256.realty.localisation.MessageContainer; import io.github.md5sha256.realty.localisation.MessageKeys; +import io.github.md5sha256.realty.settings.Settings; import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -23,6 +24,7 @@ import org.jetbrains.annotations.Nullable; import java.util.UUID; +import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.CompletableFuture; import java.util.logging.Logger; @@ -37,6 +39,7 @@ public record TeleportCommand( @NotNull Logger logger, @NotNull RealtyPaperApi api, + @NotNull AtomicReference settings, @NotNull MessageContainer messages, @NotNull SafeLocationFinder safeLocationFinder) implements CustomCommandBean.Single { @@ -110,7 +113,7 @@ private void execute(@NotNull CommandContext ctx) { return CompletableFuture.completedFuture(loc); } return safeLocationFinder.findSafeInRegion( - region.region(), region.world(), REGION_MAX_TRIES); + region.region(), region.world(), REGION_MAX_TRIES, settings.get().teleportStartHeight()); }).whenComplete((loc, ex) -> processTeleport(player, regionId, loc, ex)); } diff --git a/realty-paper/src/main/java/io/github/md5sha256/realty/command/util/SafeLocationFinder.java b/realty-paper/src/main/java/io/github/md5sha256/realty/command/util/SafeLocationFinder.java index 8756864..1e6969c 100644 --- a/realty-paper/src/main/java/io/github/md5sha256/realty/command/util/SafeLocationFinder.java +++ b/realty-paper/src/main/java/io/github/md5sha256/realty/command/util/SafeLocationFinder.java @@ -222,7 +222,8 @@ private static boolean defaultIsSafe(@NotNull Block feetBlock) { public @NotNull CompletableFuture<@Nullable Location> findSafeInRegion( @NotNull ProtectedRegion region, @NotNull World world, - int maxTries) { + int maxTries, + int teleportStartHeight) { BlockVector3 min = region.getMinimumPoint(); BlockVector3 max = region.getMaximumPoint(); @@ -231,9 +232,9 @@ private static boolean defaultIsSafe(@NotNull Block feetBlock) { int startY; int startZ = (min.z() + max.z()) / 2; - // Start searching around ground level for tall plots - if (max.y() - min.y() >= 100 && 80 <= max.y() && 80 >= min.y()) { - startY = 80; + // Start searching around the configued level (ground level) for tall plots + if (max.y() - min.y() >= 100 && teleportStartHeight <= max.y() && teleportStartHeight >= min.y()) { + startY = teleportStartHeight; } else { startY = (min.y() + max.y()) / 2; } diff --git a/realty-paper/src/main/java/io/github/md5sha256/realty/settings/Settings.java b/realty-paper/src/main/java/io/github/md5sha256/realty/settings/Settings.java index 0a7941d..37da303 100644 --- a/realty-paper/src/main/java/io/github/md5sha256/realty/settings/Settings.java +++ b/realty-paper/src/main/java/io/github/md5sha256/realty/settings/Settings.java @@ -21,7 +21,8 @@ public record Settings( @Setting("profile-reapply-per-tick") int profileReapplyPerTick, @Setting("subregion-min-volume") int subregionMinVolume, @Setting("offer-payment-duration-seconds") long offerPaymentDurationSeconds, - @Setting("subregion-tag-blacklist") @NotNull List subregionTagBlacklist + @Setting("subregion-tag-blacklist") @NotNull List subregionTagBlacklist, + @Setting("teleportation-starting-height") int teleportStartHeight ) { public Settings { @@ -37,6 +38,9 @@ public record Settings( if (subregionTagBlacklist == null) { subregionTagBlacklist = List.of(); } + if (teleportStartHeight < -64 || teleportStartHeight > 320) { + teleportStartHeight = 80; + } } } diff --git a/realty-paper/src/main/resources/settings.yml b/realty-paper/src/main/resources/settings.yml index 9e86f42..20b588b 100644 --- a/realty-paper/src/main/resources/settings.yml +++ b/realty-paper/src/main/resources/settings.yml @@ -12,4 +12,7 @@ subregion-min-volume: 20 offer-payment-duration-seconds: 86400 # Tag IDs that prevent a parent region from being subregioned. # If a region has any of these tags, it cannot be used as a parent for subregion creation. -subregion-tag-blacklist: [] \ No newline at end of file +subregion-tag-blacklist: [] +# Y-level at which the safe location finder will start looking in the case of very tall plots. +# It's advisable to set this just above the average ground level of your map. +teleportation-starting-height: 80 \ No newline at end of file From 4d5cc92b6e3efbb61f8f1130b6d2040fc91682f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Out?= <38955258+bjorn-out@users.noreply.github.com> Date: Mon, 18 May 2026 13:53:44 +0000 Subject: [PATCH 3/3] Remove world height check --- .../java/io/github/md5sha256/realty/settings/Settings.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/realty-paper/src/main/java/io/github/md5sha256/realty/settings/Settings.java b/realty-paper/src/main/java/io/github/md5sha256/realty/settings/Settings.java index 37da303..ebb22a8 100644 --- a/realty-paper/src/main/java/io/github/md5sha256/realty/settings/Settings.java +++ b/realty-paper/src/main/java/io/github/md5sha256/realty/settings/Settings.java @@ -38,9 +38,6 @@ public record Settings( if (subregionTagBlacklist == null) { subregionTagBlacklist = List.of(); } - if (teleportStartHeight < -64 || teleportStartHeight > 320) { - teleportStartHeight = 80; - } } }