Improve distance check

This commit is contained in:
Allink 2023-06-17 20:09:22 +01:00
parent 87d7ba19de
commit 42b68011ea
No known key found for this signature in database
1 changed files with 2 additions and 1 deletions

View File

@ -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!");