diff options
Diffstat (limited to 'EssentialsChat/src/com/earth2me/essentials/chat')
12 files changed, 408 insertions, 300 deletions
diff --git a/EssentialsChat/src/com/earth2me/essentials/chat/ChatStore.java b/EssentialsChat/src/com/earth2me/essentials/chat/ChatStore.java index 38239abfe..bd6a9adab 100644 --- a/EssentialsChat/src/com/earth2me/essentials/chat/ChatStore.java +++ b/EssentialsChat/src/com/earth2me/essentials/chat/ChatStore.java @@ -1,25 +1,25 @@ package com.earth2me.essentials.chat; -import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.Trade; -import com.earth2me.essentials.User; +import com.earth2me.essentials.api.IEssentials; +import com.earth2me.essentials.api.IUser; public class ChatStore { - private final User user; - private final String type; - private final Trade charge; + private final transient IUser user; + private final transient String type; + private final transient Trade charge; private long radius; - ChatStore(final IEssentials ess, final User user, final String type) + ChatStore(final IEssentials ess, final IUser user, final String type) { this.user = user; this.type = type; this.charge = new Trade(getLongType(), ess); } - public User getUser() + public IUser getUser() { return user; } @@ -34,7 +34,7 @@ public class ChatStore return type; } - public String getLongType() + public final String getLongType() { return type.length() > 0 ? "chat" : "chat-" + type; } @@ -44,7 +44,7 @@ public class ChatStore return radius; } - public void setRadius(long radius) + public void setRadius(final long radius) { this.radius = radius; } diff --git a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChat.java b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChat.java index 21a71f046..3035a75f0 100644 --- a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChat.java +++ b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChat.java @@ -1,10 +1,12 @@ package com.earth2me.essentials.chat; import static com.earth2me.essentials.I18n._; -import com.earth2me.essentials.IEssentials; +import com.earth2me.essentials.api.IEssentials; +import com.earth2me.essentials.chat.listenerlevel.EssentialsChatPlayerListenerHighest; +import com.earth2me.essentials.chat.listenerlevel.EssentialsChatPlayerListenerLowest; +import com.earth2me.essentials.chat.listenerlevel.EssentialsChatPlayerListenerNormal; import java.util.HashMap; import java.util.Map; -import java.util.concurrent.ConcurrentSkipListMap; import java.util.logging.Level; import java.util.logging.Logger; import org.bukkit.event.Event.Priority; @@ -17,7 +19,6 @@ import org.bukkit.plugin.java.JavaPlugin; public class EssentialsChat extends JavaPlugin { private static final Logger LOGGER = Logger.getLogger("Minecraft"); - private transient Map<String, IEssentialsChatListener> chatListener; @Override public void onEnable() @@ -34,35 +35,23 @@ public class EssentialsChat extends JavaPlugin return; } - chatListener = new ConcurrentSkipListMap<String, IEssentialsChatListener>(); - final Map<PlayerChatEvent, ChatStore> chatStore = new HashMap<PlayerChatEvent, ChatStore>(); + final Map<PlayerChatEvent, String> charges = new HashMap<PlayerChatEvent, String>(); - final EssentialsChatPlayerListenerLowest playerListenerLowest = new EssentialsChatPlayerListenerLowest(getServer(), ess, chatListener, chatStore); - final EssentialsChatPlayerListenerNormal playerListenerNormal = new EssentialsChatPlayerListenerNormal(getServer(), ess, chatListener, chatStore); - final EssentialsChatPlayerListenerHighest playerListenerHighest = new EssentialsChatPlayerListenerHighest(getServer(), ess, chatListener, chatStore); - pluginManager.registerEvents(playerListenerLowest, this); - pluginManager.registerEvents(playerListenerNormal, this); - pluginManager.registerEvents(playerListenerHighest, this); + final EssentialsChatPlayerListenerLowest playerListenerLowest = new EssentialsChatPlayerListenerLowest(getServer(), ess); + final EssentialsChatPlayerListenerNormal playerListenerNormal = new EssentialsChatPlayerListenerNormal(getServer(), ess, charges); + final EssentialsChatPlayerListenerHighest playerListenerHighest = new EssentialsChatPlayerListenerHighest(getServer(), ess, charges); + final EssentialsLocalChatEventListener localChatListener = new EssentialsLocalChatEventListener(getServer(), ess); + pluginManager.registerEvent(Type.PLAYER_CHAT, playerListenerLowest, Priority.Lowest, this); + pluginManager.registerEvent(Type.PLAYER_CHAT, playerListenerNormal, Priority.Normal, this); + pluginManager.registerEvent(Type.PLAYER_CHAT, playerListenerHighest, Priority.Highest, this); + pluginManager.registerEvent(Type.CUSTOM_EVENT, localChatListener, Priority.Highest, this); + LOGGER.info(_("loadinfo", this.getDescription().getName(), this.getDescription().getVersion(), "essentials team")); } @Override public void onDisable() { - if (chatListener != null) - { - chatListener.clear(); - } - } - - public void addEssentialsChatListener(final String plugin, final IEssentialsChatListener listener) - { - chatListener.put(plugin, listener); - } - - public IEssentialsChatListener removeEssentialsChatListener(final String plugin) - { - return chatListener.remove(plugin); } } diff --git a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java index ddf928725..d55cfe9cb 100644 --- a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java +++ b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java @@ -2,156 +2,180 @@ package com.earth2me.essentials.chat; import com.earth2me.essentials.ChargeException; import static com.earth2me.essentials.I18n._; -import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.Trade; -import com.earth2me.essentials.User; +import com.earth2me.essentials.api.IEssentials; +import com.earth2me.essentials.api.ISettings; +import com.earth2me.essentials.api.IUser; +import java.util.Locale; import java.util.Map; import java.util.logging.Logger; -import org.bukkit.Location; import org.bukkit.Server; -import org.bukkit.World; +import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerChatEvent; +import org.bukkit.event.player.PlayerListener; //TODO: Translate the local/spy tags -public abstract class EssentialsChatPlayer implements Listener +public abstract class EssentialsChatPlayer extends PlayerListener { protected transient IEssentials ess; protected final static Logger logger = Logger.getLogger("Minecraft"); - protected final transient Map<String, IEssentialsChatListener> listeners; - protected final transient Server server; - protected final transient Map<PlayerChatEvent, ChatStore> chatStorage; - - public EssentialsChatPlayer(final Server server, - final IEssentials ess, - final Map<String, IEssentialsChatListener> listeners, - final Map<PlayerChatEvent, ChatStore> chatStorage) + protected final transient Server server; + + public EssentialsChatPlayer(final Server server, final IEssentials ess) { this.ess = ess; - this.listeners = listeners; this.server = server; - this.chatStorage = chatStorage; } + @Override public void onPlayerChat(final PlayerChatEvent event) { } public boolean isAborted(final PlayerChatEvent event) { + return isAborted(event, "chat"); + } + + public boolean isAborted(final PlayerChatEvent event, final String command) + { if (event.isCancelled()) { return true; } - for (IEssentialsChatListener listener : listeners.values()) + + final IUser user = ess.getUser(event.getPlayer()); + if (!isAffordableFor(user, command)) { - if (listener.shouldHandleThisChat(event)) - { - return true; - } + event.setCancelled(true); + return true; } return false; } + + protected void chargeChat (final PlayerChatEvent event, final Map<PlayerChatEvent, String> charges) { + + final IUser user = ess.getUser(event.getPlayer()); + + String charge = charges.remove(event); + if (charge == null) + { + charge = "chat"; + } - public String getChatType(final String message) - { - switch (message.charAt(0)) + try { - case '!': - return "shout"; - case '?': - return "question"; - default: - return ""; + charge(user, charge); + } + catch (ChargeException e) + { + ess.getCommandHandler().showCommandError(user, charge, e); + event.setCancelled(true); } } - public ChatStore getChatStore(final PlayerChatEvent event) - { - return chatStorage.get(event); - } - - public void setChatStore(final PlayerChatEvent event, final ChatStore chatStore) + protected void charge(final CommandSender sender, final String command) throws ChargeException { - chatStorage.put(event, chatStore); + if (sender instanceof Player) + { + final Trade charge = new Trade(command, ess); + charge.charge(ess.getUser((Player)sender)); + } } - public ChatStore delChatStore(final PlayerChatEvent event) + protected boolean isAffordableFor(final CommandSender sender, final String command) { - return chatStorage.remove(event); - } + if (sender instanceof Player) + { + try + { + final Trade charge = new Trade(command, ess); + charge.isAffordableFor(ess.getUser((Player)sender)); + } + catch (ChargeException e) + { + return false; + } + } + else + { + return false; + } - protected void charge(final User user, final Trade charge) throws ChargeException - { - charge.charge(user); + return true; } - protected boolean charge(final PlayerChatEvent event, final ChatStore chatStore) + protected void formatChat(final PlayerChatEvent event) { - try + final IUser user = ess.getUser(event.getPlayer()); + if (user.isAuthorized("essentials.chat.color")) { - charge(chatStore.getUser(), chatStore.getCharge()); + event.setMessage(event.getMessage().replaceAll("&([0-9a-f])", "\u00a7$1")); } - catch (ChargeException e) + String format = ess.getGroups().getChatFormat(user); + event.setFormat(format.replace('&', '\u00a7').replace("\u00a7\u00a7", "&").replace("{DISPLAYNAME}", "%1$s").replace("{GROUP}", user.getGroup()).replace("{MESSAGE}", "%2$s").replace("{WORLDNAME}", user.getWorld().getName()).replace("{SHORTWORLDNAME}", user.getWorld().getName().substring(0, 1).toUpperCase(Locale.ENGLISH))); + } + + protected String getChatType(final String message) + { + switch (message.charAt(0)) { - ess.showError(chatStore.getUser(), e, chatStore.getLongType()); - event.setCancelled(true); - return false; + case '!': + return "shout"; + case '?': + return "question"; + //case '@': + // return "admin"; + default: + return ""; } - return true; } - protected void sendLocalChat(final PlayerChatEvent event, final ChatStore chatStore) + protected void handleLocalChat(final Map<PlayerChatEvent, String> charges, final PlayerChatEvent event) { - event.setCancelled(true); - final User sender = chatStore.getUser(); - logger.info(_("localFormat", sender.getName(), event.getMessage())); - final Location loc = sender.getLocation(); - final World world = loc.getWorld(); - - if (charge(event, chatStore) == false) - { - return; + long radius = 0; + ISettings settings = ess.getSettings(); + settings.acquireReadLock(); + try { + radius = settings.getData().getChat().getLocalRadius(); + } finally { + settings.unlock(); } + radius *= radius; + + final IUser user = ess.getUser(event.getPlayer()); + final String chatType = getChatType(event.getMessage()); + final StringBuilder command = new StringBuilder(); + command.append("chat"); - for (Player onlinePlayer : server.getOnlinePlayers()) + if (event.getMessage().length() > 0 && chatType.length() > 0) { - String type = _("chatTypeLocal"); - final User onlineUser = ess.getUser(onlinePlayer); - //TODO: remove reference to op - if (onlineUser.isIgnoredPlayer(sender.getName()) && !sender.isOp()) - { - continue; - } - if (!onlineUser.equals(sender)) - { - final Location playerLoc = onlineUser.getLocation(); - if (playerLoc.getWorld() != world) - { - continue; - } - final double delta = playerLoc.distanceSquared(loc); - - if (delta > chatStore.getRadius()) - { - if (onlineUser.isAuthorized("essentials.chat.spy")) - { - type = type.concat(_("chatTypeSpy")); - } - else - { - continue; - } - } - } + command.append("-").append(chatType); + final StringBuilder permission = new StringBuilder(); + permission.append("essentials.chat.").append(chatType); + + final StringBuilder format = new StringBuilder(); + format.append(chatType).append("Format"); + + final StringBuilder errorMsg = new StringBuilder(); + errorMsg.append("notAllowedTo").append(chatType.substring(0, 1).toUpperCase(Locale.ENGLISH)).append(chatType.substring(1)); - String message = String.format(event.getFormat(), type.concat(sender.getDisplayName()), event.getMessage()); - for (IEssentialsChatListener listener : listeners.values()) + if (user.isAuthorized(permission.toString())) { - message = listener.modifyMessage(event, onlinePlayer, message); + event.setMessage(event.getMessage().substring(1)); + event.setFormat(_(format.toString(), event.getFormat())); + charges.put(event, command.toString()); + return; } - onlineUser.sendMessage(message); + + user.sendMessage(_(errorMsg.toString())); + event.setCancelled(true); + return; } + + event.setCancelled(true); + final EssentialsLocalChatEvent localChat = new EssentialsLocalChatEvent(event, radius); + ess.getServer().getPluginManager().callEvent(localChat); } } diff --git a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerHighest.java b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerHighest.java deleted file mode 100644 index e8f785228..000000000 --- a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerHighest.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.earth2me.essentials.chat; - -import com.earth2me.essentials.IEssentials; -import java.util.Map; -import org.bukkit.Server; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.player.PlayerChatEvent; - - -public class EssentialsChatPlayerListenerHighest extends EssentialsChatPlayer -{ - public EssentialsChatPlayerListenerHighest(final Server server, - final IEssentials ess, - final Map<String, IEssentialsChatListener> listeners, - final Map<PlayerChatEvent, ChatStore> chatStorage) - { - super(server, ess, listeners, chatStorage); - } - - @EventHandler(priority = EventPriority.HIGHEST) - @Override - public void onPlayerChat(final PlayerChatEvent event) - { - final ChatStore chatStore = delChatStore(event); - if (isAborted(event)) - { - return; - } - - /** - * This file should handle charging the user for the action before returning control back - */ - charge(event, chatStore); - } -} diff --git a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerLowest.java b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerLowest.java deleted file mode 100644 index 5a8cde62d..000000000 --- a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerLowest.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.earth2me.essentials.chat; - -import com.earth2me.essentials.IEssentials; -import com.earth2me.essentials.User; -import com.earth2me.essentials.Util; -import java.util.Locale; -import java.util.Map; -import org.bukkit.Server; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.player.PlayerChatEvent; - - -public class EssentialsChatPlayerListenerLowest extends EssentialsChatPlayer -{ - public EssentialsChatPlayerListenerLowest(final Server server, - final IEssentials ess, - final Map<String, IEssentialsChatListener> listeners, - final Map<PlayerChatEvent, ChatStore> chatStorage) - { - super(server, ess, listeners, chatStorage); - } - - @EventHandler(priority = EventPriority.LOWEST) - @Override - public void onPlayerChat(final PlayerChatEvent event) - { - if (isAborted(event)) - { - return; - } - - final User user = ess.getUser(event.getPlayer()); - final ChatStore chatStore = new ChatStore(ess, user, getChatType(event.getMessage())); - setChatStore(event, chatStore); - - /** - * This listener should apply the general chat formatting only...then return control back the event handler - */ - if (user.isAuthorized("essentials.chat.color")) - { - event.setMessage(Util.replaceColor(event.getMessage())); - } - else - { - event.setMessage(Util.stripColor(event.getMessage())); - } - String group = user.getGroup(); - String world = user.getWorld().getName(); - event.setFormat(ess.getSettings().getChatFormat(group).format(new Object[] {group, world, world.substring(0, 1).toUpperCase(Locale.ENGLISH)})); - } -} diff --git a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerNormal.java b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerNormal.java deleted file mode 100644 index fdaccdc8d..000000000 --- a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerNormal.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.earth2me.essentials.chat; - -import static com.earth2me.essentials.I18n._; -import com.earth2me.essentials.IEssentials; -import com.earth2me.essentials.User; -import java.util.Locale; -import java.util.Map; -import org.bukkit.Server; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.player.PlayerChatEvent; - - -public class EssentialsChatPlayerListenerNormal extends EssentialsChatPlayer -{ - public EssentialsChatPlayerListenerNormal(final Server server, - final IEssentials ess, - final Map<String, IEssentialsChatListener> listeners, - final Map<PlayerChatEvent, ChatStore> chatStorage) - { - super(server, ess, listeners, chatStorage); - } - - @EventHandler(priority = EventPriority.NORMAL) - @Override - public void onPlayerChat(final PlayerChatEvent event) - { - if (isAborted(event)) - { - return; - } - - /** - * This file should handle detection of the local chat features... if local chat is enabled, we need to handle - * it here - */ - long radius = ess.getSettings().getChatRadius(); - if (radius < 1) - { - return; - } - radius *= radius; - - final ChatStore chatStore = getChatStore(event); - final User user = chatStore.getUser(); - chatStore.setRadius(radius); - - if (event.getMessage().length() > 1 && chatStore.getType().length() > 0) - { - final StringBuilder permission = new StringBuilder(); - permission.append("essentials.chat.").append(chatStore.getType()); - - if (user.isAuthorized(permission.toString())) - { - final StringBuilder format = new StringBuilder(); - format.append(chatStore.getType()).append("Format"); - event.setMessage(event.getMessage().substring(1)); - event.setFormat(_(format.toString(), event.getFormat())); - return; - } - - final StringBuilder errorMsg = new StringBuilder(); - errorMsg.append("notAllowedTo").append(chatStore.getType().substring(0, 1).toUpperCase(Locale.ENGLISH)).append(chatStore.getType().substring(1)); - - user.sendMessage(_(errorMsg.toString())); - event.setCancelled(true); - return; - } - - sendLocalChat(event, chatStore); - } -} diff --git a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsLocalChatEvent.java b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsLocalChatEvent.java new file mode 100644 index 000000000..fe605b89a --- /dev/null +++ b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsLocalChatEvent.java @@ -0,0 +1,100 @@ +package com.earth2me.essentials.chat; + +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.player.PlayerChatEvent; + + +public class EssentialsLocalChatEvent extends Event implements Cancellable +{ + private Player player; + private String message; + private String format = "<%1$s> %2$s"; + private long radius; + private boolean cancelled = false; + private PlayerChatEvent parentEvent = null; + + public EssentialsLocalChatEvent(final Player player, final String message, final String format, final long radius) + { + super("EssLocalChat"); + this.player = player; + this.message = message; + this.format = format; + this.radius = radius; + } + + public EssentialsLocalChatEvent(final PlayerChatEvent event, final long radius) + { + this(event.getPlayer(), event.getMessage(), event.getFormat(), radius); + this.parentEvent = event; + } + + @Override + public boolean isCancelled() + { + return cancelled; + } + + @Override + public void setCancelled(final boolean cancel) + { + this.cancelled = cancel; + } + + public String getMessage() + { + return message; + } + + public void setMessage(final String message) + { + this.message = message; + } + + public void setPlayer(final Player player) + { + this.player = player; + } + + public Player getPlayer() + { + return player; + } + + public String getFormat() + { + return format; + } + + public void setFormat(final String format) + { + // Oh for a better way to do this! + try + { + String.format(format, player, message); + } + catch (RuntimeException ex) + { + ex.fillInStackTrace(); + throw ex; + } + + this.format = format; + } + + public long getRadius() + { + return radius; + } + + public void setRadius(final long radius) + { + this.radius = radius; + } + + public PlayerChatEvent getParentEvent() + { + return parentEvent; + } +}
\ No newline at end of file diff --git a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsLocalChatEventListener.java b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsLocalChatEventListener.java new file mode 100644 index 000000000..135bfa81f --- /dev/null +++ b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsLocalChatEventListener.java @@ -0,0 +1,77 @@ +package com.earth2me.essentials.chat; + +import com.earth2me.essentials.api.IEssentials; +import com.earth2me.essentials.api.IUser; +import org.bukkit.Location; +import org.bukkit.Server; +import org.bukkit.World; +import org.bukkit.entity.Player; +import org.bukkit.event.CustomEventListener; +import org.bukkit.event.Event; +import org.bukkit.event.Listener; + +public class EssentialsLocalChatEventListener extends CustomEventListener implements Listener { + + + protected transient IEssentials ess; + protected final transient Server server; + + public EssentialsLocalChatEventListener(final Server server, final IEssentials ess) + { + this.ess = ess; + this.server = server; + } + + public void onLocalChat(final EssentialsLocalChatEvent event) { + final Player sender = event.getPlayer(); + if (event.getRadius() < 1) + { + return; + } + event.setCancelled(true); + final Location loc = sender.getLocation(); + final World world = loc.getWorld(); + + for (Player onlinePlayer : server.getOnlinePlayers()) + { + String type = "[L]"; + final IUser user = ess.getUser(onlinePlayer); + //TODO: remove reference to op + if (user.isIgnoringPlayer(sender.getName()) && !sender.isOp()) + { + continue; + } + if (!user.equals(sender)) + { + final Location playerLoc = user.getLocation(); + if (playerLoc.getWorld() != world) + { + continue; + } + final double delta = playerLoc.distanceSquared(loc); + + if (delta > event.getRadius()) + { + if (user.isAuthorized("essentials.chat.spy")) + { + type = type.concat("[Spy]"); + } + else + { + continue; + } + } + } + + final String message = String.format(event.getFormat(), type.concat(sender.getDisplayName()), event.getMessage()); + user.sendMessage(message); + } + } + + @Override + public void onCustomEvent(final Event event) { + if (event instanceof EssentialsLocalChatEvent) { + onLocalChat((EssentialsLocalChatEvent) event); + } + } +}
\ No newline at end of file diff --git a/EssentialsChat/src/com/earth2me/essentials/chat/IEssentialsChatListener.java b/EssentialsChat/src/com/earth2me/essentials/chat/IEssentialsChatListener.java deleted file mode 100644 index 5c9c5c219..000000000 --- a/EssentialsChat/src/com/earth2me/essentials/chat/IEssentialsChatListener.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.earth2me.essentials.chat; - -import org.bukkit.entity.Player; -import org.bukkit.event.player.PlayerChatEvent; - - -public interface IEssentialsChatListener -{ - boolean shouldHandleThisChat(PlayerChatEvent event); - - String modifyMessage(PlayerChatEvent event, Player target, String message); -} diff --git a/EssentialsChat/src/com/earth2me/essentials/chat/listenerlevel/EssentialsChatPlayerListenerHighest.java b/EssentialsChat/src/com/earth2me/essentials/chat/listenerlevel/EssentialsChatPlayerListenerHighest.java new file mode 100644 index 000000000..7868f2295 --- /dev/null +++ b/EssentialsChat/src/com/earth2me/essentials/chat/listenerlevel/EssentialsChatPlayerListenerHighest.java @@ -0,0 +1,32 @@ +package com.earth2me.essentials.chat.listenerlevel; + +import com.earth2me.essentials.api.IEssentials; +import com.earth2me.essentials.chat.EssentialsChatPlayer; +import java.util.Map; +import org.bukkit.Server; +import org.bukkit.event.player.PlayerChatEvent; + + +public class EssentialsChatPlayerListenerHighest extends EssentialsChatPlayer +{ + private final transient Map<PlayerChatEvent, String> charges; + + public EssentialsChatPlayerListenerHighest(final Server server, + final IEssentials ess, + final Map<PlayerChatEvent, String> charges) + { + super(server, ess); + this.charges = charges; + } + + @Override + public void onPlayerChat(final PlayerChatEvent event) + { + if (isAborted(event)) + { + return; + } + + chargeChat(event, charges); + } +} diff --git a/EssentialsChat/src/com/earth2me/essentials/chat/listenerlevel/EssentialsChatPlayerListenerLowest.java b/EssentialsChat/src/com/earth2me/essentials/chat/listenerlevel/EssentialsChatPlayerListenerLowest.java new file mode 100644 index 000000000..37394c3e6 --- /dev/null +++ b/EssentialsChat/src/com/earth2me/essentials/chat/listenerlevel/EssentialsChatPlayerListenerLowest.java @@ -0,0 +1,26 @@ +package com.earth2me.essentials.chat.listenerlevel; + +import com.earth2me.essentials.api.IEssentials; +import com.earth2me.essentials.chat.EssentialsChatPlayer; +import org.bukkit.Server; +import org.bukkit.event.player.PlayerChatEvent; + + +public class EssentialsChatPlayerListenerLowest extends EssentialsChatPlayer +{ + public EssentialsChatPlayerListenerLowest(final Server server, final IEssentials ess) + { + super(server, ess); + } + + @Override + public void onPlayerChat(final PlayerChatEvent event) + { + if (isAborted(event)) + { + return; + } + + formatChat(event); + } +}
\ No newline at end of file diff --git a/EssentialsChat/src/com/earth2me/essentials/chat/listenerlevel/EssentialsChatPlayerListenerNormal.java b/EssentialsChat/src/com/earth2me/essentials/chat/listenerlevel/EssentialsChatPlayerListenerNormal.java new file mode 100644 index 000000000..c1a9968ef --- /dev/null +++ b/EssentialsChat/src/com/earth2me/essentials/chat/listenerlevel/EssentialsChatPlayerListenerNormal.java @@ -0,0 +1,32 @@ +package com.earth2me.essentials.chat.listenerlevel; + +import com.earth2me.essentials.api.IEssentials; +import com.earth2me.essentials.chat.EssentialsChatPlayer; +import java.util.Map; +import org.bukkit.Server; +import org.bukkit.event.player.PlayerChatEvent; + + +public class EssentialsChatPlayerListenerNormal extends EssentialsChatPlayer +{ + private final transient Map<PlayerChatEvent, String> charges; + + public EssentialsChatPlayerListenerNormal(final Server server, + final IEssentials ess, + final Map<PlayerChatEvent, String> charges) + { + super(server, ess); + this.charges = charges; + } + + @Override + public void onPlayerChat(final PlayerChatEvent event) + { + if (isAborted(event)) + { + return; + } + + handleLocalChat(charges, event); + } +} |