From 37b0cdeace97c6bb8ff8e32e1aba87216bb4aa8e Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Sun, 10 Jun 2018 19:35:34 +1000 Subject: [PATCH] Revert "Don't cancel chat event" This reverts commit dc5fc5af4762ef0ee4a1b8658729e232b70207cc. --- .../bukkit/listeners/PlayerEvents.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 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 80bfa4b79..a57c5f924 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java @@ -769,10 +769,8 @@ public class PlayerEvents extends PlotListener implements Listener { if (plot == null) { return; } + event.setCancelled(true); String message = event.getMessage(); - if (plotPlayer.hasPermission("plots.chat.color")) { - event.setMessage(C.color(message)); - } String format = C.PLOT_CHAT_FORMAT.s(); String sender = event.getPlayer().getDisplayName(); PlotId id = plot.getId(); @@ -790,14 +788,21 @@ public class PlayerEvents extends PlotListener implements Listener { } } } - String newFormat = ChatColor.translateAlternateColorCodes('&', format.replace("%plot_id%", id.x + ";" + id.y).replace("%sender%", "%1$s").replace("%msg%", "%2$s")); - event.setFormat(newFormat); + String partial = ChatColor.translateAlternateColorCodes('&',format.replace("%plot_id%", id.x + ";" + id.y).replace("%sender%", sender)); + if (plotPlayer.hasPermission("plots.chat.color")) { + message = C.color(message); + } + String full = partial.replace("%msg%", message); + for (Player receiver : recipients) { + receiver.sendMessage(full); + } if (!spies.isEmpty()) { String spyMessage = C.PLOT_CHAT_SPY_FORMAT.s().replace("%plot_id%", id.x + ";" + id.y).replace("%sender%", sender).replace("%msg%", message); for (Player player : spies) { player.sendMessage(spyMessage); } } + PS.debug(full); } @EventHandler(priority = EventPriority.LOWEST)