From bcb7c234072fbbb7840f3abc0568c8a47e7eee21 Mon Sep 17 00:00:00 2001 From: mmenanno <1358708+mmenanno@users.noreply.github.com> Date: Sat, 7 Feb 2026 14:10:17 -0500 Subject: [PATCH 1/2] feat: add per-warp distance overrides Allow admins to set a custom distance limit for individual warps via the new `warp-distance-overrides` config section. Setting a value of -1 removes the distance limit entirely for that warp, while positive values override the default maximum-teleport-distance for that warp. Closes #145 --- .../advancedteleport/config/MainConfig.java | 15 +++++++++++ .../managers/TeleportTrackingManager.java | 3 ++- .../utilities/ConditionChecker.java | 8 +++++- .../utilities/DistanceLimiter.java | 25 +++++++++++++++++++ config/config.yml | 7 ++++++ 5 files changed, 56 insertions(+), 2 deletions(-) diff --git a/AdvancedTeleport-Bukkit/src/main/java/io/github/niestrat99/advancedteleport/config/MainConfig.java b/AdvancedTeleport-Bukkit/src/main/java/io/github/niestrat99/advancedteleport/config/MainConfig.java index d7ca74b6..ab43dd69 100644 --- a/AdvancedTeleport-Bukkit/src/main/java/io/github/niestrat99/advancedteleport/config/MainConfig.java +++ b/AdvancedTeleport-Bukkit/src/main/java/io/github/niestrat99/advancedteleport/config/MainConfig.java @@ -67,6 +67,7 @@ public final class MainConfig extends ATConfig { public ConfigOption MONITOR_ALL_TELEPORTS; public PerCommandOption DISTANCE_LIMITS; public ConfigOption CUSTOM_DISTANCE_LIMITS; + public ConfigOption WARP_DISTANCE_OVERRIDES; public ConfigOption ENABLE_TELEPORT_LIMITATIONS; public ConfigOption MONITOR_ALL_TELEPORTS_LIMITS; public ConfigOption WORLD_RULES; @@ -497,6 +498,19 @@ The key (vip-distance) and group name (VIP) do not have to be different, this is To combine the two, you can use at.member.distance...vip-distance.\ """); + makeSectionLenient("warp-distance-overrides"); + addComment( + "warp-distance-overrides", + """ + Per-warp distance overrides. + Set a specific distance limit for individual warps. + Use -1 to remove the distance limit entirely for that warp. + Example: + warp-distance-overrides: + caverns: -1 + temple: 5000\ + """); + addSection("Teleportation Limitations"); addComment( @@ -1145,6 +1159,7 @@ public void postSave() { new PerCommandOption<>( "per-command-distance-limitations", "maximum-teleport-distance"); CUSTOM_DISTANCE_LIMITS = new ConfigOption<>("custom-distance-limitations"); + WARP_DISTANCE_OVERRIDES = new ConfigOption<>("warp-distance-overrides"); ENABLE_TELEPORT_LIMITATIONS = new ConfigOption<>("enable-teleport-limitations"); MONITOR_ALL_TELEPORTS_LIMITS = new ConfigOption<>("monitor-all-teleports-limitations"); diff --git a/AdvancedTeleport-Bukkit/src/main/java/io/github/niestrat99/advancedteleport/managers/TeleportTrackingManager.java b/AdvancedTeleport-Bukkit/src/main/java/io/github/niestrat99/advancedteleport/managers/TeleportTrackingManager.java index 49631fd6..bf5033a5 100644 --- a/AdvancedTeleport-Bukkit/src/main/java/io/github/niestrat99/advancedteleport/managers/TeleportTrackingManager.java +++ b/AdvancedTeleport-Bukkit/src/main/java/io/github/niestrat99/advancedteleport/managers/TeleportTrackingManager.java @@ -166,7 +166,8 @@ public void onTeleport(ATTeleportEvent e) { e.getFromLocation(), e.getToLocation(), e.getType().getName(), - e.getPlayer()); + e.getPlayer(), + e.getLocName()); if (result != null) { CustomMessages.sendMessage( e.getPlayer(), diff --git a/AdvancedTeleport-Bukkit/src/main/java/io/github/niestrat99/advancedteleport/utilities/ConditionChecker.java b/AdvancedTeleport-Bukkit/src/main/java/io/github/niestrat99/advancedteleport/utilities/ConditionChecker.java index cde22a58..6bdbea03 100644 --- a/AdvancedTeleport-Bukkit/src/main/java/io/github/niestrat99/advancedteleport/utilities/ConditionChecker.java +++ b/AdvancedTeleport-Bukkit/src/main/java/io/github/niestrat99/advancedteleport/utilities/ConditionChecker.java @@ -64,6 +64,12 @@ public class ConditionChecker { public static @Nullable String canTeleport( Location fromLoc, Location toLoc, String command, Player teleportingPlayer) { + return canTeleport(fromLoc, toLoc, command, teleportingPlayer, null); + } + + public static @Nullable String canTeleport( + Location fromLoc, Location toLoc, String command, Player teleportingPlayer, + @Nullable String locName) { // Use debug print CoreClass.debug( @@ -81,7 +87,7 @@ public class ConditionChecker { && !teleportingPlayer.hasPermission("at.admin.bypass.distance-limit") && fromLoc.getWorld() == toLoc.getWorld() && !DistanceLimiter.canTeleport( - toLoc, fromLoc, command, ATPlayer.getPlayer(teleportingPlayer))) { + toLoc, fromLoc, command, ATPlayer.getPlayer(teleportingPlayer), locName)) { return "Error.tooFarAway"; } diff --git a/AdvancedTeleport-Bukkit/src/main/java/io/github/niestrat99/advancedteleport/utilities/DistanceLimiter.java b/AdvancedTeleport-Bukkit/src/main/java/io/github/niestrat99/advancedteleport/utilities/DistanceLimiter.java index 7f740e9a..4f35236d 100644 --- a/AdvancedTeleport-Bukkit/src/main/java/io/github/niestrat99/advancedteleport/utilities/DistanceLimiter.java +++ b/AdvancedTeleport-Bukkit/src/main/java/io/github/niestrat99/advancedteleport/utilities/DistanceLimiter.java @@ -3,13 +3,38 @@ import io.github.niestrat99.advancedteleport.api.ATPlayer; import io.github.niestrat99.advancedteleport.config.MainConfig; +import io.github.thatsmusic99.configurationmaster.api.ConfigSection; import org.bukkit.Location; +import org.jetbrains.annotations.Nullable; public class DistanceLimiter { public static boolean canTeleport( Location loc1, Location loc2, String command, ATPlayer player) { + return canTeleport(loc1, loc2, command, player, null); + } + + public static boolean canTeleport( + Location loc1, Location loc2, String command, ATPlayer player, @Nullable String locName) { if (command == null && !MainConfig.get().MONITOR_ALL_TELEPORTS.get()) return true; + + // Check for per-warp distance overrides when the command is "warp" + if ("warp".equalsIgnoreCase(command) && locName != null && !locName.isEmpty()) { + ConfigSection overrides = MainConfig.get().WARP_DISTANCE_OVERRIDES.get(); + if (overrides != null) { + Object overrideValue = overrides.get(locName); + if (overrideValue != null) { + int overrideDistance = overrides.getInteger(locName); + if (overrideDistance == -1) return true; + if (overrideDistance > 0) { + if (!MainConfig.get().ENABLE_DISTANCE_LIMITATIONS.get()) return true; + if (loc1.getWorld() != loc2.getWorld()) return true; + return loc1.distanceSquared(loc2) < (long) overrideDistance * overrideDistance; + } + } + } + } + int allowedDistance = player.getDistanceLimitation(command, loc2.getWorld()); if (MainConfig.get().ENABLE_DISTANCE_LIMITATIONS.get() && allowedDistance > 0) { if (loc1.getWorld() != loc2.getWorld()) return true; diff --git a/config/config.yml b/config/config.yml index 9c8d66e6..c5025985 100644 --- a/config/config.yml +++ b/config/config.yml @@ -226,6 +226,13 @@ per-command-distance-limitations: # Distance limit for /back back: default +# Per-warp distance overrides. +# Set a specific distance limit for individual warps. +# Use -1 to remove the distance limit entirely for that warp. +# warp-distance-overrides: +# caverns: -1 +# temple: 5000 + ############################### # Teleportation Limitations # ############################### From 40604d47501e3263eafebc5e32fe398f76acf180 Mon Sep 17 00:00:00 2001 From: mmenanno <1358708+mmenanno@users.noreply.github.com> Date: Mon, 16 Feb 2026 12:04:01 -0500 Subject: [PATCH 2/2] fix: remove redundant config comment per PR review --- .../io/github/niestrat99/advancedteleport/config/MainConfig.java | 1 - 1 file changed, 1 deletion(-) diff --git a/AdvancedTeleport-Bukkit/src/main/java/io/github/niestrat99/advancedteleport/config/MainConfig.java b/AdvancedTeleport-Bukkit/src/main/java/io/github/niestrat99/advancedteleport/config/MainConfig.java index ab43dd69..090c2de0 100644 --- a/AdvancedTeleport-Bukkit/src/main/java/io/github/niestrat99/advancedteleport/config/MainConfig.java +++ b/AdvancedTeleport-Bukkit/src/main/java/io/github/niestrat99/advancedteleport/config/MainConfig.java @@ -502,7 +502,6 @@ The key (vip-distance) and group name (VIP) do not have to be different, this is addComment( "warp-distance-overrides", """ - Per-warp distance overrides. Set a specific distance limit for individual warps. Use -1 to remove the distance limit entirely for that warp. Example: