From 83d0b8cebbe017377204f550de6ef1b5e6298d61 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 25 Aug 2015 00:35:37 +1000 Subject: [PATCH] Revert some plot chat changes. - Having chat for that plotworld will force it on all players without the bypass permission - Not having it will require the player to opt into plot chat --- .../bukkit/listeners/ChatListener.java | 64 ------------------- .../bukkit/listeners/PlayerEvents.java | 12 +--- .../bukkit/object/BukkitPlayer.java | 2 +- 3 files changed, 3 insertions(+), 75 deletions(-) delete mode 100644 src/main/java/com/plotsquared/bukkit/listeners/ChatListener.java diff --git a/src/main/java/com/plotsquared/bukkit/listeners/ChatListener.java b/src/main/java/com/plotsquared/bukkit/listeners/ChatListener.java deleted file mode 100644 index bc3aae84b..000000000 --- a/src/main/java/com/plotsquared/bukkit/listeners/ChatListener.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.plotsquared.bukkit.listeners; - -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.player.AsyncPlayerChatEvent; - -import com.intellectualcrafters.plot.PS; -import com.intellectualcrafters.plot.config.C; -import com.intellectualcrafters.plot.object.Location; -import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.object.PlotWorld; - -import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.Permissions; -import com.intellectualcrafters.plot.util.StringMan; -import com.intellectualcrafters.plot.util.UUIDHandler; -import com.plotsquared.bukkit.util.BukkitUtil; - -/** - * Created 2015-07-13 for PlotSquaredGit - * - * @author Citymonstret - */ -public class ChatListener implements Listener { - - @EventHandler(priority = EventPriority.LOWEST) - public void onChat(final AsyncPlayerChatEvent event) { - final Player player = event.getPlayer(); - final String world = player.getWorld().getName(); - if (!PS.get().isPlotWorld(world)) { - return; - } - final PlotWorld plotworld = PS.get().getPlotWorld(world); - final PlotPlayer plr = BukkitUtil.getPlayer(player); - if (!plotworld.PLOT_CHAT && (plr.getAttribute("chat"))) { - return; - } - final Location loc = BukkitUtil.getLocation(player); - final Plot plot = MainUtil.getPlot(loc); - if (plot == null) { - return; - } - event.setCancelled(true); - final String message = event.getMessage(); - final String sender = event.getPlayer().getDisplayName(); - final PlotId id = plot.id; - String toSend = StringMan.replaceAll(C.PLOT_CHAT_FORMAT.s(), "%plot_id%", id.x + ";" + id.y, "%sender%", sender, "%msg%", message); - PS.debug("FORMAT: " + event.getFormat()); - PS.debug("MESSAGE: " + event.getMessage()); - for (PlotPlayer recipient : UUIDHandler.getPlayers().values()) { - if (plot.equals(recipient.getCurrentPlot())) { - recipient.sendMessage(toSend); - } - else if (Permissions.hasPermission(recipient, C.PERMISSION_COMMANDS_CHAT)) { - recipient.sendMessage(toSend); - } - } - } - -} diff --git a/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java b/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java index fe764e97c..35c8c64d0 100644 --- a/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java @@ -606,21 +606,14 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen public void onChat(final AsyncPlayerChatEvent event) { final Player player = event.getPlayer(); final String world = player.getWorld().getName(); - if (!PS.get().isPlotWorld(world)) { - return; - } final PlotWorld plotworld = PS.get().getPlotWorld(world); - - if (!plotworld.PLOT_CHAT) { + if (plotworld == null) { return; } - final PlotPlayer plr = BukkitUtil.getPlayer(player); - - if (!plr.getAttribute("chat")) { + if (!plotworld.PLOT_CHAT && !plr.getAttribute("chat")) { return; } - final Location loc = BukkitUtil.getLocation(player); final Plot plot = MainUtil.getPlot(loc); if (plot == null) { @@ -641,7 +634,6 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen format = format.replaceAll("%plot_id%", id.x + ";" + id.y).replaceAll("%sender%", "%s").replaceAll("%msg%", "%s"); format = ChatColor.translateAlternateColorCodes('&', format); event.setFormat(format); - event.setMessage(message); } @EventHandler(priority = EventPriority.HIGHEST) diff --git a/src/main/java/com/plotsquared/bukkit/object/BukkitPlayer.java b/src/main/java/com/plotsquared/bukkit/object/BukkitPlayer.java index f39b45fa7..35965283f 100644 --- a/src/main/java/com/plotsquared/bukkit/object/BukkitPlayer.java +++ b/src/main/java/com/plotsquared/bukkit/object/BukkitPlayer.java @@ -162,7 +162,7 @@ public class BukkitPlayer extends PlotPlayer { @Override public boolean getAttribute(String key) { key = "plotsquared_user_attributes." + key; - if (EconHandler.manager == null) { + if (EconHandler.manager == null || player.hasPermission("plotsquared_user_attributes.*")) { Object v = getMeta(key); return v == null ? false : (Boolean) v; }