summaryrefslogtreecommitdiffstats
path: root/EssentialsChat/src/com
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2011-12-17 17:40:47 +0000
committerKHobbits <rob@khobbits.co.uk>2011-12-17 17:40:47 +0000
commit556c990eff34a4848fe92afa43f27cd81505f05a (patch)
tree699abebb1d2eb5cc338c39eb0b2ce17514f11af6 /EssentialsChat/src/com
parent618f58c3f38115d9d9bdc790190f8bff8b85c4da (diff)
downloadEssentials-556c990eff34a4848fe92afa43f27cd81505f05a.tar
Essentials-556c990eff34a4848fe92afa43f27cd81505f05a.tar.gz
Essentials-556c990eff34a4848fe92afa43f27cd81505f05a.tar.lz
Essentials-556c990eff34a4848fe92afa43f27cd81505f05a.tar.xz
Essentials-556c990eff34a4848fe92afa43f27cd81505f05a.zip
EssentialsChat cleaning.
Diffstat (limited to 'EssentialsChat/src/com')
-rw-r--r--EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChat.java31
-rw-r--r--EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java135
-rw-r--r--EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerHighest.java53
-rw-r--r--EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerLowest.java38
-rw-r--r--EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerNormal.java79
-rw-r--r--EssentialsChat/src/com/earth2me/essentials/chat/EssentialsLocalChatEvent.java100
-rw-r--r--EssentialsChat/src/com/earth2me/essentials/chat/EssentialsLocalChatEventListener.java78
-rw-r--r--EssentialsChat/src/com/earth2me/essentials/chat/IEssentialsChatListener.java12
-rw-r--r--EssentialsChat/src/com/earth2me/essentials/chat/listenerlevel/EssentialsChatPlayerListenerHighest.java32
-rw-r--r--EssentialsChat/src/com/earth2me/essentials/chat/listenerlevel/EssentialsChatPlayerListenerLowest.java26
-rw-r--r--EssentialsChat/src/com/earth2me/essentials/chat/listenerlevel/EssentialsChatPlayerListenerNormal.java32
11 files changed, 355 insertions, 261 deletions
diff --git a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChat.java b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChat.java
index 265322255..3035a75f0 100644
--- a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChat.java
+++ b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChat.java
@@ -2,9 +2,11 @@ package com.earth2me.essentials.chat;
import static com.earth2me.essentials.I18n._;
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,8 +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()
@@ -35,16 +35,17 @@ public class EssentialsChat extends JavaPlugin
return;
}
- chatListener = new ConcurrentSkipListMap<String, IEssentialsChatListener>();
final Map<PlayerChatEvent, String> charges = new HashMap<PlayerChatEvent, String>();
-
- final EssentialsChatPlayerListenerLowest playerListenerLowest = new EssentialsChatPlayerListenerLowest(getServer(), ess, chatListener);
- final EssentialsChatPlayerListenerNormal playerListenerNormal = new EssentialsChatPlayerListenerNormal(getServer(), ess, chatListener, charges);
- final EssentialsChatPlayerListenerHighest playerListenerHighest = new EssentialsChatPlayerListenerHighest(getServer(), ess, chatListener, charges);
+
+ 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"));
}
@@ -52,19 +53,5 @@ public class EssentialsChat extends JavaPlugin
@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 349cc7e28..17cc7c2f3 100644
--- a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java
+++ b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java
@@ -5,11 +5,10 @@ import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.api.IEssentials;
import com.earth2me.essentials.Trade;
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.player.PlayerChatEvent;
@@ -20,16 +19,15 @@ 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 Server server;
- public EssentialsChatPlayer(Server server, IEssentials ess, Map<String, IEssentialsChatListener> listeners)
+ public EssentialsChatPlayer(final Server server, final IEssentials ess)
{
this.ess = ess;
- this.listeners = listeners;
this.server = server;
}
+ @Override
public void onPlayerChat(final PlayerChatEvent event)
{
}
@@ -45,13 +43,6 @@ public abstract class EssentialsChatPlayer extends PlayerListener
{
return true;
}
- for (IEssentialsChatListener listener : listeners.values())
- {
- if (listener.shouldHandleThisChat(event))
- {
- return true;
- }
- }
final IUser user = ess.getUser(event.getPlayer());
if (!isAffordableFor(user, command))
@@ -61,17 +52,25 @@ public abstract class EssentialsChatPlayer extends PlayerListener
}
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);
}
}
@@ -106,47 +105,69 @@ public abstract class EssentialsChatPlayer extends PlayerListener
return true;
}
- protected void sendLocalChat(final IUser sender, final long radius, final PlayerChatEvent event)
+ protected void formatChat(final PlayerChatEvent event)
+ {
+ final IUser user = ess.getUser(event.getPlayer());
+ if (user.isAuthorized("essentials.chat.color"))
+ {
+ event.setMessage(event.getMessage().replaceAll("&([0-9a-f])", "\u00a7$1"));
+ }
+ event.setFormat(ess.getSettings().getChatFormat(user.getGroup()).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))
+ {
+ case '!':
+ return "shout";
+ case '?':
+ return "question";
+ //case '@':
+ // return "admin";
+ default:
+ return "";
+ }
+ }
+
+ protected void handleLocalChat(final Map<PlayerChatEvent, String> charges, final PlayerChatEvent event)
{
- event.setCancelled(true);
- logger.info(_("localFormat", sender.getName(), event.getMessage()));
- final Location loc = sender.getLocation();
- final World world = loc.getWorld();
- for (Player onlinePlayer : server.getOnlinePlayers())
+ long radius = ess.getSettings().getChatRadius();
+ radius *= radius;
+
+ final IUser user = ess.getUser(event.getPlayer());
+ final String chatType = getChatType(event.getMessage());
+ final StringBuilder command = new StringBuilder();
+ command.append("chat");
+
+ if (event.getMessage().length() > 0 && chatType.length() > 0)
{
- 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 > radius)
- {
- if (user.isAuthorized("essentials.chat.spy"))
- {
- type = type.concat("[Spy]");
- }
- else
- {
- continue;
- }
- }
- }
+ command.append("-").append(chatType);
+ final StringBuilder permission = new StringBuilder();
+ permission.append("essentials.chat.").append(chatType);
- String message = String.format(event.getFormat(), type.concat(sender.getDisplayName()), event.getMessage());
- for (IEssentialsChatListener listener : listeners.values())
+ 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));
+
+ 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;
}
- user.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 d2098f4a6..000000000
--- a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerHighest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package com.earth2me.essentials.chat;
-
-import com.earth2me.essentials.ChargeException;
-import com.earth2me.essentials.api.IEssentials;
-import com.earth2me.essentials.api.IUser;
-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<String, IEssentialsChatListener> listeners,
- final Map<PlayerChatEvent, String> charges)
- {
- super(server, ess, listeners);
- this.charges = charges;
- }
-
- @Override
- public void onPlayerChat(final PlayerChatEvent event)
- {
- String charge = charges.remove(event);
- if (charge == null)
- {
- charge = "chat";
- }
- if (isAborted(event))
- {
- return;
- }
-
- /**
- * This file should handle charging the user for the action before returning control back
- */
- final IUser user = ess.getUser(event.getPlayer());
-
- try
- {
- charge(user, charge);
- }
- catch (ChargeException e)
- {
- ess.getCommandHandler().showCommandError(user, charge, e);
- event.setCancelled(true);
- return;
- }
- }
-}
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 80b725d28..000000000
--- a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerLowest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package com.earth2me.essentials.chat;
-
-import com.earth2me.essentials.api.IEssentials;
-import com.earth2me.essentials.api.IUser;
-import java.util.Locale;
-import java.util.Map;
-import org.bukkit.Server;
-import org.bukkit.event.player.PlayerChatEvent;
-
-
-public class EssentialsChatPlayerListenerLowest extends EssentialsChatPlayer
-{
- public EssentialsChatPlayerListenerLowest(final Server server,
- final IEssentials ess,
- final Map<String, IEssentialsChatListener> listeners)
- {
- super(server, ess, listeners);
- }
-
- @Override
- public void onPlayerChat(final PlayerChatEvent event)
- {
- if (isAborted(event))
- {
- return;
- }
-
- /**
- * This listener should apply the general chat formatting only...then return control back the event handler
- */
- final IUser user = ess.getUser(event.getPlayer());
- if (user.isAuthorized("essentials.chat.color"))
- {
- event.setMessage(event.getMessage().replaceAll("&([0-9a-f])", "\u00a7$1"));
- }
- event.setFormat(ess.getSettings().getChatFormat(user.getGroup()).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)));
- }
-}
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 34aba2be0..000000000
--- a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerNormal.java
+++ /dev/null
@@ -1,79 +0,0 @@
-package com.earth2me.essentials.chat;
-
-import static com.earth2me.essentials.I18n._;
-import com.earth2me.essentials.api.IEssentials;
-import com.earth2me.essentials.api.IUser;
-import java.util.Locale;
-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<String, IEssentialsChatListener> listeners,
- final Map<PlayerChatEvent, String> charges)
- {
- super(server, ess, listeners);
- this.charges = charges;
- }
-
- @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
- */
- final String chatType = getChatType(event.getMessage());
- final StringBuilder command = new StringBuilder();
- command.append("chat");
-
- if (chatType.length() > 0)
- {
- command.append("-").append(chatType);
- }
- long radius = ess.getSettings().getChatRadius();
- if (radius < 1)
- {
- return;
- }
- radius *= radius;
- final IUser user = ess.getUser(event.getPlayer());
-
- if (event.getMessage().length() > 0 && chatType.length() > 0)
- {
- 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));
-
- if (user.isAuthorized(permission.toString()))
- {
- event.setMessage(event.getMessage().substring(1));
- event.setFormat(_(format.toString(), event.getFormat()));
- charges.put(event, command.toString());
- return;
- }
-
- user.sendMessage(_(errorMsg.toString()));
- event.setCancelled(true);
- return;
- }
-
- sendLocalChat(user, radius, event);
- }
-}
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..5d024a852
--- /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("LocalChat");
+ 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..df3c959f4
--- /dev/null
+++ b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsLocalChatEventListener.java
@@ -0,0 +1,78 @@
+package com.earth2me.essentials.chat;
+
+import com.earth2me.essentials.api.IEssentials;
+import com.earth2me.essentials.api.IUser;
+import com.earth2me.essentials.chat.EssentialsLocalChatEvent;
+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);
+ }
+}