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
This commit is contained in:
boy0001 2015-08-25 00:35:37 +10:00
parent 3bc3b51a27
commit 83d0b8cebb
3 changed files with 3 additions and 75 deletions

View File

@ -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);
}
}
}
}

View File

@ -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)

View File

@ -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;
}