From 42b68011eafaab38bfb0c75800df4ee1558074d9 Mon Sep 17 00:00:00 2001 From: Allink Date: Sat, 17 Jun 2023 20:09:22 +0100 Subject: [PATCH] Improve distance check --- .../me/totalfreedom/totalfreedommod/MovementValidator.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/MovementValidator.java b/src/main/java/me/totalfreedom/totalfreedommod/MovementValidator.java index 10b82409..30520467 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/MovementValidator.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/MovementValidator.java @@ -44,8 +44,9 @@ public class MovementValidator extends FreedomService final Player player = event.getPlayer(); Location from = event.getFrom(); Location to = event.getTo(); + double distance = from.distanceSquared(to); - if (to.getX() >= from.getX() + MAX_DISTANCE_TRAVELED || to.getY() >= from.getY() + MAX_DISTANCE_TRAVELED || to.getZ() >= from.getZ() + MAX_DISTANCE_TRAVELED) + if (distance >= MAX_DISTANCE_TRAVELED) { event.setCancelled(true); player.kickPlayer(ChatColor.RED + "You were moving too quickly!");