Well, this is an odd and kludgy fix... only thing I can find that allows the integration to work correctly and not give an error whether EssentialsChat is present or not

This commit is contained in:
Brettflan 2011-07-20 19:31:28 -05:00
parent b650387dbc
commit bd5d7e185e
2 changed files with 29 additions and 12 deletions

View File

@ -0,0 +1,12 @@
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);
}

View File

@ -192,18 +192,23 @@ public class Factions extends JavaPlugin {
Plugin test = this.getServer().getPluginManager().getPlugin("EssentialsChat"); Plugin test = this.getServer().getPluginManager().getPlugin("EssentialsChat");
if (test != null) { if (test != null) {
essChat = (EssentialsChat)test; try {
essChat.addEssentialsChatListener("Factions", new IEssentialsChatListener() { essChat = (EssentialsChat)test;
public boolean shouldHandleThisChat(PlayerChatEvent event) essChat.addEssentialsChatListener("Factions", new IEssentialsChatListener() {
{ public boolean shouldHandleThisChat(PlayerChatEvent event)
return shouldLetFactionsHandleThisChat(event); {
} return shouldLetFactionsHandleThisChat(event);
public String modifyMessage(PlayerChatEvent event, Player target, String message) }
{ public String modifyMessage(PlayerChatEvent event, Player target, String message)
return message.replace("{FACTION}", getPlayerFactionTagRelation(event.getPlayer(), target)).replace("{FACTION_TITLE}", getPlayerTitle(event.getPlayer())); {
} return message.replace("{FACTION}", getPlayerFactionTagRelation(event.getPlayer(), target)).replace("{FACTION_TITLE}", getPlayerTitle(event.getPlayer()));
}); }
Factions.log("Found and will integrate chat with "+test.getDescription().getFullName()); });
Factions.log("Found and will integrate chat with "+test.getDescription().getFullName());
}
catch (NoSuchMethodError ex) {
essChat = null;
}
} }
} }
private void unhookEssentialsChat() { private void unhookEssentialsChat() {