More changes to the EssentialsChat API for Factions

This commit is contained in:
snowleo 2011-07-20 12:12:49 +02:00
parent 3b59dd0b02
commit 0483635a5c
3 changed files with 9 additions and 37 deletions

View File

@ -39,8 +39,13 @@ public class EssentialsChat extends JavaPlugin
chatListener.clear();
}
public void addEssentialsChatListener(String plugin, IEssentialsChatListener listener)
public void addEssentialsChatListener(final String plugin, final IEssentialsChatListener listener)
{
chatListener.put(plugin, listener);
}
public IEssentialsChatListener removeEssentialsChatListener(final String plugin)
{
return chatListener.remove(plugin);
}
}

View File

@ -12,7 +12,6 @@ import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerListener;
//import org.mcteam.factions.Factions;
public class EssentialsChatPlayerListener extends PlayerListener
{
@ -20,7 +19,6 @@ public class EssentialsChatPlayerListener extends PlayerListener
private final transient IEssentials ess;
private final transient Server server;
private final transient Map<String, IEssentialsChatListener> listeners;
//private static Factions factions = null;
public EssentialsChatPlayerListener(final Server server, final IEssentials ess, final Map<String, IEssentialsChatListener> listeners)
{
@ -37,8 +35,6 @@ public class EssentialsChatPlayerListener extends PlayerListener
return;
}
//if (factions != null && (factions.shouldLetFactionsHandleThisChat(event)))
// return;
for (IEssentialsChatListener listener : listeners.values())
{
if (listener.shouldHandleThisChat(event))
@ -120,40 +116,10 @@ public class EssentialsChatPlayerListener extends PlayerListener
for (IEssentialsChatListener listener : listeners.values())
{
message = listener.modifyMessage(event, message);
message = listener.modifyMessage(event, p, 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)
{
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);
}*/
}

View File

@ -1,5 +1,6 @@
package com.earth2me.essentials.chat;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerChatEvent;
@ -7,5 +8,5 @@ public interface IEssentialsChatListener
{
boolean shouldHandleThisChat(PlayerChatEvent event);
String modifyMessage(PlayerChatEvent event, String message);
String modifyMessage(PlayerChatEvent event, Player target, String message);
}