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 053e2eed8..646688a3f 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java @@ -622,13 +622,12 @@ public class PlayerEvents extends PlotListener implements Listener { String sender = event.getPlayer().getDisplayName(); PlotId id = plot.getId(); Set recipients = event.getRecipients(); + Set spies = new HashSet<>(); recipients.clear(); for (Entry entry : UUIDHandler.getPlayers().entrySet()) { PlotPlayer pp = entry.getValue(); if (pp.getAttribute("chatspy")) { - String spy = event.getFormat(); - spy = String.format(spy, sender, message); - pp.sendMessage(spy); + spies.add(((BukkitPlayer) pp).player); } else { Plot current = pp.getCurrentPlot(); if (current != null && current.getBasePlot(false).equals(plot)) { @@ -637,10 +636,19 @@ public class PlayerEvents extends PlotListener implements Listener { } } 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); } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/config/C.java b/Core/src/main/java/com/intellectualcrafters/plot/config/C.java index 1aed01381..67c483713 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -624,6 +624,7 @@ public enum C { /* * Chat */ + PLOT_CHAT_SPY_FORMAT("$2[$1Plot Spy$2][$1%plot_id%$2] $1%sender%$2: $1%msg%", "Chat"), PLOT_CHAT_FORMAT("$2[$1Plot Chat$2][$1%plot_id%$2] $1%sender%$2: $1%msg%", "Chat"), PLOT_CHAT_FORCED("$2This world forces everyone to use plot chat.", "Chat"), PLOT_CHAT_ON("$4Plot chat enabled.", "Chat"),