summaryrefslogtreecommitdiffstats
path: root/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListener.java
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2011-07-19 11:26:23 +0200
committersnowleo <schneeleo@gmail.com>2011-07-19 11:26:23 +0200
commitdc99efb0a73f13be687a19e4b77623e6cc0dfe68 (patch)
tree52083e21c55f3cbf29c9dd588062c5ecbe249c33 /EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListener.java
parent6a156ede687c4a43b042ce6d7aa4ab2be8a19794 (diff)
downloadEssentials-dc99efb0a73f13be687a19e4b77623e6cc0dfe68.tar
Essentials-dc99efb0a73f13be687a19e4b77623e6cc0dfe68.tar.gz
Essentials-dc99efb0a73f13be687a19e4b77623e6cc0dfe68.tar.lz
Essentials-dc99efb0a73f13be687a19e4b77623e6cc0dfe68.tar.xz
Essentials-dc99efb0a73f13be687a19e4b77623e6cc0dfe68.zip
Rewritten Factions hook, so we don't need Factions in our code.
Diffstat (limited to 'EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListener.java')
-rw-r--r--EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListener.java81
1 files changed, 46 insertions, 35 deletions
diff --git a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListener.java b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListener.java
index 60af127ad..28adf9c2c 100644
--- a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListener.java
+++ b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListener.java
@@ -3,31 +3,30 @@ package com.earth2me.essentials.chat;
import com.earth2me.essentials.IEssentials;
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.entity.Player;
import org.bukkit.event.player.PlayerChatEvent;
-import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerListener;
-import org.bukkit.plugin.Plugin;
-import org.bukkit.plugin.PluginManager;
-
-import org.mcteam.factions.Factions;
+//import org.mcteam.factions.Factions;
public class EssentialsChatPlayerListener extends PlayerListener
{
private static final Logger LOGGER = Logger.getLogger("Minecraft");
private final transient IEssentials ess;
private final transient Server server;
- private static Factions factions = null;
+ private final transient Map<String, IEssentialsChatListener> listeners;
+ //private static Factions factions = null;
- public EssentialsChatPlayerListener(final Server server, final IEssentials ess)
+ public EssentialsChatPlayerListener(final Server server, final IEssentials ess, final Map<String, IEssentialsChatListener> listeners)
{
this.server = server;
this.ess = ess;
+ this.listeners = listeners;
}
@Override
@@ -38,8 +37,15 @@ public class EssentialsChatPlayerListener extends PlayerListener
return;
}
- if (factions != null && (factions.shouldLetFactionsHandleThisChat(event)))
- return;
+ //if (factions != null && (factions.shouldLetFactionsHandleThisChat(event)))
+ // return;
+ for (IEssentialsChatListener listener : listeners.values())
+ {
+ if (listener.shouldHandleThisChat(event))
+ {
+ return;
+ }
+ }
final User user = ess.getUser(event.getPlayer());
@@ -112,37 +118,42 @@ public class EssentialsChatPlayerListener extends PlayerListener
}
String message = String.format(event.getFormat(), user.getDisplayName(), event.getMessage());
- if (factions != null)
- message = message.replace("{FACTION}", factions.getPlayerFactionTagRelation(event.getPlayer(), p)).replace("{FACTION_TITLE}", factions.getPlayerTitle(event.getPlayer()));
+ for (IEssentialsChatListener listener : listeners.values())
+ {
+ message = listener.modifyMessage(message);
+
+ }
+ //if (factions != null)
+ // message = message.replace("{FACTION}", factions.getPlayerFactionTagRelation(event.getPlayer(), p)).replace("{FACTION_TITLE}", factions.getPlayerTitle(event.getPlayer()));
u.sendMessage(message);
}
}
- protected static void checkFactions(PluginManager pm)
+ /*protected static void checkFactions(PluginManager pm)
{
- if (factions != null)
- return;
-
- Plugin factionsPlugin = pm.getPlugin("Factions");
- if (factionsPlugin == null)
- return;
-
- factions = (Factions)factionsPlugin;
- try
- { // make sure Factions is sufficiently up-to-date
- if (factions.hookSupportVersion() < 1)
- factions = null;
- }
- catch (NoSuchMethodError ex)
- { // if not, we can't work with it, so don't bother
- factions = null;
- }
-
- if (factions == null)
- return;
-
- // normally a good thing, but we'll skip it to let Factions handle faction tags for global messages
- //factions.handleFactionTagExternally(true);
+ if (factions != null)
+ return;
+
+ Plugin factionsPlugin = pm.getPlugin("Factions");
+ if (factionsPlugin == null)
+ return;
+
+ factions = (Factions)factionsPlugin;
+ try
+ { // make sure Factions is sufficiently up-to-date
+ if (factions.hookSupportVersion() < 1)
+ factions = null;
+ }
+ catch (NoSuchMethodError ex)
+ { // if not, we can't work with it, so don't bother
+ factions = null;
}
+
+ if (factions == null)
+ return;
+
+ // normally a good thing, but we'll skip it to let Factions handle faction tags for global messages
+ //factions.handleFactionTagExternally(true);
+ }*/
}