From cc6af2cd2ad0ca13f510cfbd313d5944983650b6 Mon Sep 17 00:00:00 2001 From: Archy-X <63976867+Archy-X@users.noreply.github.com> Date: Sun, 28 Jul 2024 12:07:56 -0700 Subject: [PATCH] Fix cannot measure distance error in PositionHandler --- .../auraskills/bukkit/antiafk/handler/PositionHandler.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/antiafk/handler/PositionHandler.java b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/antiafk/handler/PositionHandler.java index 9261cff14..2b5ef96c8 100644 --- a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/antiafk/handler/PositionHandler.java +++ b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/antiafk/handler/PositionHandler.java @@ -5,6 +5,8 @@ import org.bukkit.entity.Player; import org.jetbrains.annotations.Nullable; +import java.util.Objects; + public record PositionHandler(double maxDistance, int minCount) { public boolean failsCheck(CheckData data, Player player) { @@ -15,6 +17,11 @@ public boolean failsCheck(CheckData data, Player player) { if (prevLoc == null) return false; + if (!Objects.equals(currentLoc.getWorld(), currentLoc.getWorld())) { + data.resetCount(); + return false; + } + if (currentLoc.distanceSquared(prevLoc) <= maxDistance * maxDistance) { data.incrementCount(); } else {