From e6ccb3be553647ef29a164dc512fe1b2b430f965 Mon Sep 17 00:00:00 2001 From: ZepsiZola <49735083+ZepsiZola@users.noreply.github.com> Date: Mon, 6 May 2024 00:44:39 +0100 Subject: [PATCH] Fixed MinRadius Issue (#211) * Fixed MinRadius Issue No longer sends players to exclusively the corners of the map. Now sends them to anywhere where x or z is above the MinRadius (while both being below the MaxRadius) * Fixed MinRadius Issue No longer sends players to exclusively the corners of the map. Now sends them to anywhere where x or z is above the MinRadius (while both being below the MaxRadius) Fixes this issue. https://github.com/RonanPlugins/BetterRTP/issues/210 * Update QueueHandler.java * MaxRadius and MinRadius fix --- .../references/rtpinfo/QueueHandler.java | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/main/java/me/SuperRonanCraft/BetterRTP/references/rtpinfo/QueueHandler.java b/src/main/java/me/SuperRonanCraft/BetterRTP/references/rtpinfo/QueueHandler.java index 4d14ab7..8a42c6a 100644 --- a/src/main/java/me/SuperRonanCraft/BetterRTP/references/rtpinfo/QueueHandler.java +++ b/src/main/java/me/SuperRonanCraft/BetterRTP/references/rtpinfo/QueueHandler.java @@ -105,19 +105,13 @@ public class QueueHandler implements Listener { //Randomly queues up some safe l } public static boolean isInSquare(Location loc, RTPWorld rtpWorld) { - int center_x = rtpWorld.getCenterX(); - int center_z = rtpWorld.getCenterZ(); - int radius = rtpWorld.getMaxRadius(); + int radius_max = rtpWorld.getMaxRadius(); int radius_min = rtpWorld.getMinRadius(); - int x = loc.getBlockX(); - int z = loc.getBlockZ(); - boolean xright = x <= center_x + radius && x >= center_x + radius_min; - boolean xleft = x >= center_x - radius && x <= center_x - radius_min; - if (!(xleft || xright)) - return false; - boolean zbottom = z <= center_z + radius && z >= center_z + radius_min; - boolean ztop = z >= center_z - radius && z <= center_z - radius_min; - return ztop || zbottom; + int x = loc.getBlockX() - rtpWorld.getCenterX(); + int z = loc.getBlockZ() - rtpWorld.getCenterZ(); + return ((Math.abs(x)>=radius_min || Math.abs(z)>=radius_min) && (Math.abs(x) <= radius_max && Math.abs(z) <= radius_max)); + // Returns true if the x or z coordinate is above the MinRadius and if they are both under the MaxRadius. Returns false otherwise. + // (All locations provided should be below the MaxRadius anyway, but I put it in just in-case.) } }