mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 07:06:44 +01:00
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:
parent
3bc3b51a27
commit
83d0b8cebb
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user