From 8fe4334058eef1d22b4b458c944058dc216fe98c Mon Sep 17 00:00:00 2001 From: M0diis Date: Tue, 27 Feb 2024 10:11:52 +0200 Subject: [PATCH 1/3] Resolve issue #223 --- .../java/at/helpch/chatchat/util/ChannelUtils.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 c9e70fa5..10bb9637 100644 --- a/plugin/src/main/java/at/helpch/chatchat/util/ChannelUtils.java +++ b/plugin/src/main/java/at/helpch/chatchat/util/ChannelUtils.java @@ -5,6 +5,7 @@ import at.helpch.chatchat.api.user.User; import at.helpch.chatchat.channel.ChatChannel; import org.bukkit.Location; +import org.bukkit.World; import org.jetbrains.annotations.NotNull; import java.util.List; @@ -50,9 +51,17 @@ public static boolean isTargetWithinRadius( return true; } - if (radius != -1 && source instanceof ChatUser) { + if (radius != -1 && source instanceof ChatUser ) { final Location sourceLocation = ((ChatUser) source).player().getLocation(); final Location targetLocation = ((ChatUser) target).player().getLocation(); + + final World sourceWorld = sourceLocation.getWorld(); + final World targetWorld = targetLocation.getWorld(); + + if(sourceWorld != null && targetWorld != null && !sourceWorld.getName().equals(targetWorld.getName())) { + return false; + } + final int relativeX = targetLocation.getBlockX() - sourceLocation.getBlockX(); final int relativeZ = targetLocation.getBlockZ() - sourceLocation.getBlockZ(); From 2ddfd321bf9855f5d8fa9ff30f6bb3f4d78dddf4 Mon Sep 17 00:00:00 2001 From: M0diis Date: Tue, 27 Feb 2024 10:12:21 +0200 Subject: [PATCH 2/3] Whitespace fix --- plugin/src/main/java/at/helpch/chatchat/util/ChannelUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 10bb9637..b5081ecd 100644 --- a/plugin/src/main/java/at/helpch/chatchat/util/ChannelUtils.java +++ b/plugin/src/main/java/at/helpch/chatchat/util/ChannelUtils.java @@ -51,7 +51,7 @@ public static boolean isTargetWithinRadius( return true; } - if (radius != -1 && source instanceof ChatUser ) { + if (radius != -1 && source instanceof ChatUser) { final Location sourceLocation = ((ChatUser) source).player().getLocation(); final Location targetLocation = ((ChatUser) target).player().getLocation(); From aa99703926afa2a74780e1cc2d6f9e4373fb5491 Mon Sep 17 00:00:00 2001 From: M0diis Date: Tue, 27 Feb 2024 20:26:58 +0200 Subject: [PATCH 3/3] Change world name comparison to UID --- plugin/src/main/java/at/helpch/chatchat/util/ChannelUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 b5081ecd..5f0b9650 100644 --- a/plugin/src/main/java/at/helpch/chatchat/util/ChannelUtils.java +++ b/plugin/src/main/java/at/helpch/chatchat/util/ChannelUtils.java @@ -58,7 +58,7 @@ public static boolean isTargetWithinRadius( final World sourceWorld = sourceLocation.getWorld(); final World targetWorld = targetLocation.getWorld(); - if(sourceWorld != null && targetWorld != null && !sourceWorld.getName().equals(targetWorld.getName())) { + if(sourceWorld != null && targetWorld != null && !sourceWorld.getUID().equals(targetWorld.getUID())) { return false; }