diff --git a/plugin/src/main/java/at/helpch/chatchat/util/ChannelUtils.java b/plugin/src/main/java/at/helpch/chatchat/util/ChannelUtils.java index 16ec5fd..48dd3e0 100644 --- a/plugin/src/main/java/at/helpch/chatchat/util/ChannelUtils.java +++ b/plugin/src/main/java/at/helpch/chatchat/util/ChannelUtils.java @@ -54,7 +54,7 @@ public static boolean isTargetWithinRadius( } if (radius != -1 && source instanceof ChatUser) { - final Location targetLocation = targetChatUser.player().getLocation(); + final Location sourceLocation = targetChatUser.player().getLocation(); final Location targetLocation = ((ChatUser) target).player().getLocation(); final World sourceWorld = sourceLocation.getWorld(); @@ -64,6 +64,9 @@ public static boolean isTargetWithinRadius( return false; } + final int relativeX = targetLocation.getBlockX() - sourceLocation.getBlockX(); + final int relativeZ = targetLocation.getBlockZ() - sourceLocation.getBlockZ(); + return relativeX*relativeX + relativeZ*relativeZ <= radius*radius; }