summaryrefslogtreecommitdiffstats
path: root/EssentialsChat
diff options
context:
space:
mode:
Diffstat (limited to 'EssentialsChat')
-rw-r--r--EssentialsChat/nbproject/build-impl.xml17
-rw-r--r--EssentialsChat/nbproject/genfiles.properties4
-rw-r--r--EssentialsChat/nbproject/project.properties9
-rw-r--r--EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChat.java44
-rw-r--r--EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java152
-rw-r--r--EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListener.java146
-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/plugin.yml2
10 files changed, 376 insertions, 168 deletions
diff --git a/EssentialsChat/nbproject/build-impl.xml b/EssentialsChat/nbproject/build-impl.xml
index 4dc2d2659..80a5b5256 100644
--- a/EssentialsChat/nbproject/build-impl.xml
+++ b/EssentialsChat/nbproject/build-impl.xml
@@ -20,10 +20,10 @@ is divided into following sections:
-->
<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="EssentialsChat-impl">
- <fail message="Please build using Ant 1.7.1 or higher.">
+ <fail message="Please build using Ant 1.8.0 or higher.">
<condition>
<not>
- <antversion atleast="1.7.1"/>
+ <antversion atleast="1.8.0"/>
</not>
</condition>
</fail>
@@ -223,6 +223,7 @@ is divided into following sections:
<property name="javac.fork" value="${jdkBug6558476}"/>
<property name="jar.index" value="false"/>
<property name="jar.index.metainf" value="${jar.index}"/>
+ <property name="copylibs.rebase" value="true"/>
<available file="${meta.inf.dir}/persistence.xml" property="has.persistence.xml"/>
</target>
<target name="-post-init">
@@ -409,6 +410,7 @@ is divided into following sections:
<property environment="env"/>
<resolve name="profiler.current.path" value="${profiler.info.pathvar}"/>
<java classname="@{classname}" dir="${profiler.info.dir}" fork="true" jvm="${profiler.info.jvm}">
+ <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
<jvmarg value="${profiler.info.jvmargs.agent}"/>
<jvmarg line="${profiler.info.jvmargs}"/>
<env key="${profiler.info.pathvar}" path="${profiler.info.agentpath}:${profiler.current.path}"/>
@@ -539,7 +541,7 @@ is divided into following sections:
</chainedmapper>
</pathconvert>
<taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
- <copylibs compress="${jar.compress}" index="${jar.index}" indexMetaInf="${jar.index.metainf}" jarfile="${dist.jar}" manifest="@{manifest}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
+ <copylibs compress="${jar.compress}" index="${jar.index}" indexMetaInf="${jar.index.metainf}" jarfile="${dist.jar}" manifest="@{manifest}" rebase="${copylibs.rebase}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
<fileset dir="${build.classes.dir}"/>
<manifest>
<attribute name="Class-Path" value="${jar.classpath}"/>
@@ -871,6 +873,14 @@ is divided into following sections:
-->
<target depends="init" if="have.sources" name="-javadoc-build">
<mkdir dir="${dist.javadoc.dir}"/>
+ <condition else="" property="javadoc.endorsed.classpath.cmd.line.arg" value="-J${endorsed.classpath.cmd.line.arg}">
+ <and>
+ <isset property="endorsed.classpath.cmd.line.arg"/>
+ <not>
+ <equals arg1="${endorsed.classpath.cmd.line.arg}" arg2=""/>
+ </not>
+ </and>
+ </condition>
<javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
<classpath>
<path path="${javac.classpath}"/>
@@ -882,6 +892,7 @@ is divided into following sections:
<include name="**/*.java"/>
<exclude name="*.java"/>
</fileset>
+ <arg line="${javadoc.endorsed.classpath.cmd.line.arg}"/>
</javadoc>
<copy todir="${dist.javadoc.dir}">
<fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
diff --git a/EssentialsChat/nbproject/genfiles.properties b/EssentialsChat/nbproject/genfiles.properties
index 95704bf4b..98d505913 100644
--- a/EssentialsChat/nbproject/genfiles.properties
+++ b/EssentialsChat/nbproject/genfiles.properties
@@ -4,5 +4,5 @@ build.xml.stylesheet.CRC32=28e38971@1.38.2.45
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=7c7f517b
-nbproject/build-impl.xml.script.CRC32=2447bdf5
-nbproject/build-impl.xml.stylesheet.CRC32=0ae3a408@1.44.1.45
+nbproject/build-impl.xml.script.CRC32=52184b61
+nbproject/build-impl.xml.stylesheet.CRC32=fcddb364@1.50.1.46
diff --git a/EssentialsChat/nbproject/project.properties b/EssentialsChat/nbproject/project.properties
index 867228a92..8cf7e9081 100644
--- a/EssentialsChat/nbproject/project.properties
+++ b/EssentialsChat/nbproject/project.properties
@@ -28,6 +28,7 @@ auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blank
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLinesBeforeClass=2
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.classDeclBracePlacement=NEW_LINE
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.expand-tabs=false
+auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.importGroupsOrder=*
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.indent-shift-width=4
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.indentCasesFromSwitch=false
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.methodDeclBracePlacement=NEW_LINE
@@ -36,6 +37,7 @@ auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.place
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeElseOnNewLine=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeFinallyOnNewLine=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeWhileOnNewLine=true
+auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.separateImportGroups=false
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceAfterTypeCast=false
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaces-per-tab=4
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.tab-size=4
@@ -61,12 +63,12 @@ dist.jar=${dist.dir}/EssentialsChat.jar
dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath=
excludes=
-file.reference.bukkit-0.0.1-SNAPSHOT.jar=../lib/bukkit-0.0.1-SNAPSHOT.jar
+file.reference.bukkit.jar=../lib/bukkit.jar
includes=**
jar.compress=true
javac.classpath=\
${reference.Essentials.jar}:\
- ${file.reference.bukkit-0.0.1-SNAPSHOT.jar}
+ ${file.reference.bukkit.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
@@ -77,8 +79,7 @@ javac.target=1.6
javac.test.classpath=\
${javac.classpath}:\
${build.classes.dir}:\
- ${libs.junit.classpath}:\
- ${libs.junit_4.classpath}
+ ${libs.junit_4.10.classpath}
javac.test.processorpath=\
${javac.test.classpath}
javadoc.additionalparam=
diff --git a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChat.java b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChat.java
index 7a10d9a92..25ce85cc8 100644
--- a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChat.java
+++ b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChat.java
@@ -1,13 +1,15 @@
package com.earth2me.essentials.chat;
+import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.IEssentials;
-import com.earth2me.essentials.Util;
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;
import org.bukkit.event.Event.Type;
+import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
@@ -15,34 +17,52 @@ import org.bukkit.plugin.java.JavaPlugin;
public class EssentialsChat extends JavaPlugin
{
private static final Logger LOGGER = Logger.getLogger("Minecraft");
- private Map<String, IEssentialsChatListener> chatListener;
+ private transient Map<String, IEssentialsChatListener> chatListener;
+
+ @Override
public void onEnable()
{
final PluginManager pluginManager = getServer().getPluginManager();
final IEssentials ess = (IEssentials)pluginManager.getPlugin("Essentials");
-
- chatListener = new HashMap<String, IEssentialsChatListener>();
-
- final EssentialsChatPlayerListener playerListener = new EssentialsChatPlayerListener(getServer(), ess, chatListener);
- pluginManager.registerEvent(Type.PLAYER_CHAT, playerListener, Priority.High, this);
if (!this.getDescription().getVersion().equals(ess.getDescription().getVersion()))
{
- LOGGER.log(Level.WARNING, Util.i18n("versionMismatchAll"));
+ LOGGER.log(Level.WARNING, _("versionMismatchAll"));
}
- LOGGER.info(Util.format("loadinfo", this.getDescription().getName(), this.getDescription().getVersion(), "essentials team"));
+ if (!ess.isEnabled())
+ {
+ this.setEnabled(false);
+ 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);
+ 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);
+
+ LOGGER.info(_("loadinfo", this.getDescription().getName(), this.getDescription().getVersion(), "essentials team"));
}
+ @Override
public void onDisable()
{
- chatListener.clear();
+ 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
new file mode 100644
index 000000000..2d6e1ae4e
--- /dev/null
+++ b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java
@@ -0,0 +1,152 @@
+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 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;
+import org.bukkit.event.player.PlayerListener;
+
+//TODO: Translate the local/spy tags
+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;
+
+ public EssentialsChatPlayer(Server server, IEssentials ess, Map<String, IEssentialsChatListener> listeners)
+ {
+ this.ess = ess;
+ this.listeners = listeners;
+ this.server = server;
+ }
+
+ 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())
+ {
+ if (listener.shouldHandleThisChat(event))
+ {
+ return true;
+ }
+ }
+
+ final User user = ess.getUser(event.getPlayer());
+ if (!isAffordableFor(user, command))
+ {
+ event.setCancelled(true);
+ return true;
+ }
+ return false;
+ }
+
+ public String getChatType(final String message)
+ {
+ switch (message.charAt(0))
+ {
+ case '!':
+ return "shout";
+ case '?':
+ return "question";
+ default:
+ return "";
+ }
+ }
+
+ protected void charge(final CommandSender sender, final String command) throws ChargeException
+ {
+ if (sender instanceof Player)
+ {
+ final Trade charge = new Trade(command, ess);
+ charge.charge(ess.getUser((Player)sender));
+ }
+ }
+
+ protected boolean isAffordableFor(final CommandSender sender, final String command)
+ {
+ 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;
+ }
+
+ return true;
+ }
+
+ protected void sendLocalChat(final User sender, final long radius, 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())
+ {
+ String type = "[L]";
+ final User user = ess.getUser(onlinePlayer);
+ //TODO: remove reference to op
+ if (user.isIgnoredPlayer(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;
+ }
+ }
+ }
+
+ String message = String.format(event.getFormat(), type.concat(sender.getDisplayName()), event.getMessage());
+ for (IEssentialsChatListener listener : listeners.values())
+ {
+ message = listener.modifyMessage(event, onlinePlayer, message);
+ }
+ user.sendMessage(message);
+ }
+ }
+}
diff --git a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListener.java b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListener.java
deleted file mode 100644
index 85e821e7f..000000000
--- a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListener.java
+++ /dev/null
@@ -1,146 +0,0 @@
-package com.earth2me.essentials.chat;
-
-import com.earth2me.essentials.ChargeException;
-import com.earth2me.essentials.IEssentials;
-import com.earth2me.essentials.Trade;
-import com.earth2me.essentials.User;
-import com.earth2me.essentials.Util;
-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;
-import org.bukkit.event.player.PlayerListener;
-
-
-public class EssentialsChatPlayerListener extends PlayerListener
-{
- private static final Logger LOGGER = Logger.getLogger("Minecraft");
- private final transient IEssentials ess;
- private final transient Server server;
- private final transient Map<String, IEssentialsChatListener> listeners;
-
- public EssentialsChatPlayerListener(final Server server, final IEssentials ess, final Map<String, IEssentialsChatListener> listeners)
- {
- this.server = server;
- this.ess = ess;
- this.listeners = listeners;
- }
-
- @Override
- public void onPlayerChat(final PlayerChatEvent event)
- {
- if (event.isCancelled())
- {
- return;
- }
-
- for (IEssentialsChatListener listener : listeners.values())
- {
- if (listener.shouldHandleThisChat(event))
- {
- return;
- }
- }
-
- final User user = ess.getUser(event.getPlayer());
-
- if (user.isAuthorized("essentials.chat.color"))
- {
- event.setMessage(event.getMessage().replaceAll("&([0-9a-f])", "§$1"));
- }
-
- event.setFormat(ess.getSettings().getChatFormat(user.getGroup()).replace('&', '§').replace("§§", "&").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()));
-
- long radius = ess.getSettings().getChatRadius();
- if (radius < 1)
- {
- return;
- }
- radius *= radius;
-
- try {
- if (event.getMessage().startsWith("!") && event.getMessage().length() > 1)
- {
- if (user.isAuthorized("essentials.chat.shout"))
- {
- charge(user,"chat-shout");
- event.setMessage(event.getMessage().substring(1));
- event.setFormat(Util.format("shoutFormat", event.getFormat()));
- return;
- }
- user.sendMessage(Util.i18n("notAllowedToShout"));
- event.setCancelled(true);
- return;
- }
-
- if (event.getMessage().startsWith("?") && event.getMessage().length() > 1)
- {
- if (user.isAuthorized("essentials.chat.question"))
- {
- charge(user,"chat-question");
- event.setMessage(event.getMessage().substring(1));
- event.setFormat(Util.format("questionFormat", event.getFormat()));
- return;
- }
- user.sendMessage(Util.i18n("notAllowedToQuestion"));
- event.setCancelled(true);
- return;
- }
- }
- catch (ChargeException ex)
- {
- ess.showError(user, ex, "Shout");
- return;
- }
-
- event.setCancelled(true);
- LOGGER.info(Util.format("localFormat", user.getName(), event.getMessage()));
-
- final Location loc = user.getLocation();
- final World world = loc.getWorld();
- final int x = loc.getBlockX();
- final int y = loc.getBlockY();
- final int z = loc.getBlockZ();
-
- for (Player p : server.getOnlinePlayers())
- {
- final User u = ess.getUser(p);
- if (u.isIgnoredPlayer(user.getName()) && !user.isOp())
- {
- continue;
- }
- if (!u.equals(user) && !u.isAuthorized("essentials.chat.spy"))
- {
- final Location l = u.getLocation();
- final int dx = x - l.getBlockX();
- final int dy = y - l.getBlockY();
- final int dz = z - l.getBlockZ();
- final long delta = dx*dx + dy*dy + dz*dz;
- if (delta > radius || world != l.getWorld())
- {
- continue;
- }
- }
- String message = String.format(event.getFormat(), user.getDisplayName(), event.getMessage());
-
- for (IEssentialsChatListener listener : listeners.values())
- {
- message = listener.modifyMessage(event, p, message);
- }
-
- u.sendMessage(message);
- }
- }
- protected void charge(final CommandSender sender, final String command) throws ChargeException
- {
- if (sender instanceof Player)
- {
- final Trade charge = new Trade(command, ess);
- charge.charge(ess.getUser((Player)sender));
- }
- }
-}
diff --git a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerHighest.java b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerHighest.java
new file mode 100644
index 000000000..22989d4f9
--- /dev/null
+++ b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerHighest.java
@@ -0,0 +1,53 @@
+package com.earth2me.essentials.chat;
+
+import com.earth2me.essentials.ChargeException;
+import com.earth2me.essentials.IEssentials;
+import com.earth2me.essentials.User;
+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 User user = ess.getUser(event.getPlayer());
+
+ try
+ {
+ charge(user, charge);
+ }
+ catch (ChargeException e)
+ {
+ ess.showError(user, e, charge);
+ event.setCancelled(true);
+ return;
+ }
+ }
+}
diff --git a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerLowest.java b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerLowest.java
new file mode 100644
index 000000000..de5757951
--- /dev/null
+++ b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerLowest.java
@@ -0,0 +1,38 @@
+package com.earth2me.essentials.chat;
+
+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.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 User 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
new file mode 100644
index 000000000..4e3cbefc0
--- /dev/null
+++ b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerNormal.java
@@ -0,0 +1,79 @@
+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.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 User 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/plugin.yml b/EssentialsChat/src/plugin.yml
index d3f5d38df..cc129f825 100644
--- a/EssentialsChat/src/plugin.yml
+++ b/EssentialsChat/src/plugin.yml
@@ -5,6 +5,6 @@ main: com.earth2me.essentials.chat.EssentialsChat
version: TeamCity
website: http://www.earth2me.net:8001/
description: Provides chat control features for Essentials. Requires Permissions.
-authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology]
+authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, KHobbits, Okamosy]
depend: [Essentials]
#softdepend: [Factions] \ No newline at end of file