From bd5d7e185ef90306781a60b0d42bf0323d10acfc Mon Sep 17 00:00:00 2001 From: Brettflan Date: Wed, 20 Jul 2011 19:31:28 -0500 Subject: [PATCH] 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 --- .../chat/IEssentialsChatListener.java | 12 ++++++++ src/com/massivecraft/factions/Factions.java | 29 +++++++++++-------- 2 files changed, 29 insertions(+), 12 deletions(-) create mode 100644 src/com/earth2me/essentials/chat/IEssentialsChatListener.java diff --git a/src/com/earth2me/essentials/chat/IEssentialsChatListener.java b/src/com/earth2me/essentials/chat/IEssentialsChatListener.java new file mode 100644 index 00000000..5c9c5c21 --- /dev/null +++ b/src/com/earth2me/essentials/chat/IEssentialsChatListener.java @@ -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); +} diff --git a/src/com/massivecraft/factions/Factions.java b/src/com/massivecraft/factions/Factions.java index 567df3a2..5d4ab97e 100644 --- a/src/com/massivecraft/factions/Factions.java +++ b/src/com/massivecraft/factions/Factions.java @@ -192,18 +192,23 @@ public class Factions extends JavaPlugin { Plugin test = this.getServer().getPluginManager().getPlugin("EssentialsChat"); if (test != null) { - essChat = (EssentialsChat)test; - essChat.addEssentialsChatListener("Factions", new IEssentialsChatListener() { - public boolean shouldHandleThisChat(PlayerChatEvent event) - { - return shouldLetFactionsHandleThisChat(event); - } - public String modifyMessage(PlayerChatEvent event, Player target, String message) - { - 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()); + try { + essChat = (EssentialsChat)test; + essChat.addEssentialsChatListener("Factions", new IEssentialsChatListener() { + public boolean shouldHandleThisChat(PlayerChatEvent event) + { + return shouldLetFactionsHandleThisChat(event); + } + public String modifyMessage(PlayerChatEvent event, Player target, String message) + { + 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()); + } + catch (NoSuchMethodError ex) { + essChat = null; + } } } private void unhookEssentialsChat() {