Saber-Factions/src/com/massivecraft/factions/integration/EssentialsFeatures.java
Brettflan 77a7b2d85c New Spout feature, for Spoutcraft client users only: current territory info will now be permanently shown at top of screen, instead of being echoed out to chat as you move around
New conf.json setting "spoutTerritoryDisplayPosition" to set the screen position at which the current territory is shown. 0 = disabled, 1 = top left, 2 = top center, 3 (default) = top right.
Moved all integration code to separate package, ofr better code organization. Also moved EssentialsChat integration code out to separate file in there, allowing us to safely remove our copy IEssentialsChatListener.java file (which is otherwise needed to prevent a nasty NoClassDefFoundError).
2011-10-05 05:13:54 -05:00

42 lines
1.3 KiB
Java

package com.massivecraft.factions.integration;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.plugin.Plugin;
import com.massivecraft.factions.Factions;
import com.earth2me.essentials.chat.EssentialsChat;
import com.earth2me.essentials.chat.IEssentialsChatListener;
public class EssentialsFeatures {
private static EssentialsChat essChat;
public static void integrateChat(EssentialsChat instance) {
essChat = instance;
try {
essChat.addEssentialsChatListener("Factions", new IEssentialsChatListener() {
public boolean shouldHandleThisChat(PlayerChatEvent event)
{
return Factions.instance.shouldLetFactionsHandleThisChat(event);
}
public String modifyMessage(PlayerChatEvent event, Player target, String message)
{
return message.replace("{FACTION}", Factions.instance.getPlayerFactionTagRelation(event.getPlayer(), target)).replace("{FACTION_TITLE}", Factions.instance.getPlayerTitle(event.getPlayer()));
}
});
Factions.log("Found and will integrate chat with "+essChat.getDescription().getFullName());
}
catch (NoSuchMethodError ex) {
essChat = null;
}
}
public static void unhookChat() {
if (essChat != null) {
essChat.removeEssentialsChatListener("Factions");
}
}
}