From ea5ffbeb77971b90d9664093f1b1ef9f433ace1d Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Thu, 25 Oct 2018 10:51:18 +0100 Subject: [PATCH] Cancel plot chat if message event is cancelled to allow for swear block/etc --- .../java/com/plotsquared/bukkit/listeners/PlayerEvents.java | 5 ++++- .../java/com/plotsquared/nukkit/listeners/PlayerEvents.java | 5 ++++- .../java/com/plotsquared/sponge/listener/MainListener.java | 3 +++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java index fa4577e26..972c26dfe 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java @@ -757,8 +757,11 @@ public class PlayerEvents extends PlotListener implements Listener { } } - @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) + @EventHandler(priority = EventPriority.LOW) public void onChat(AsyncPlayerChatEvent event) { + if (event.isCancelled()) + return; + PlotPlayer plotPlayer = BukkitUtil.getPlayer(event.getPlayer()); Location location = plotPlayer.getLocation(); PlotArea area = location.getPlotArea(); diff --git a/Nukkit/src/main/java/com/plotsquared/nukkit/listeners/PlayerEvents.java b/Nukkit/src/main/java/com/plotsquared/nukkit/listeners/PlayerEvents.java index 0fef4ef4d..ec00e0691 100644 --- a/Nukkit/src/main/java/com/plotsquared/nukkit/listeners/PlayerEvents.java +++ b/Nukkit/src/main/java/com/plotsquared/nukkit/listeners/PlayerEvents.java @@ -553,8 +553,11 @@ public class PlayerEvents extends PlotListener implements Listener { } } - @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) + @EventHandler(priority = EventPriority.LOW) public void onChat(PlayerChatEvent event) { + if (event.isCancelled()) + return; + PlotPlayer plotPlayer = NukkitUtil.getPlayer(event.getPlayer()); Location location = plotPlayer.getLocation(); PlotArea area = location.getPlotArea(); diff --git a/Sponge/src/main/java/com/plotsquared/sponge/listener/MainListener.java b/Sponge/src/main/java/com/plotsquared/sponge/listener/MainListener.java index 47e570682..693709e8c 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/listener/MainListener.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/listener/MainListener.java @@ -86,6 +86,9 @@ public class MainListener { @Listener public void onChat(MessageEvent event) { // TODO + if (event.isMessageCancelled()) + return; + Player player = SpongeUtil.getCause(event.getCause(), Player.class); if (player == null) { return;