2011-10-05 12:13:54 +02:00
|
|
|
package com.massivecraft.factions.integration;
|
|
|
|
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.event.player.PlayerChatEvent;
|
|
|
|
|
2011-10-08 22:03:44 +02:00
|
|
|
import com.massivecraft.factions.P;
|
2011-10-05 12:13:54 +02:00
|
|
|
|
|
|
|
import com.earth2me.essentials.chat.EssentialsChat;
|
|
|
|
import com.earth2me.essentials.chat.IEssentialsChatListener;
|
|
|
|
|
|
|
|
|
2011-10-08 22:03:44 +02:00
|
|
|
public class EssentialsFeatures
|
|
|
|
{
|
2011-10-05 12:13:54 +02:00
|
|
|
private static EssentialsChat essChat;
|
|
|
|
|
2011-10-08 22:03:44 +02:00
|
|
|
public static void integrateChat(EssentialsChat instance)
|
|
|
|
{
|
2011-10-05 12:13:54 +02:00
|
|
|
essChat = instance;
|
2011-10-08 22:03:44 +02:00
|
|
|
try
|
|
|
|
{
|
|
|
|
essChat.addEssentialsChatListener("Factions", new IEssentialsChatListener()
|
|
|
|
{
|
2011-10-05 12:13:54 +02:00
|
|
|
public boolean shouldHandleThisChat(PlayerChatEvent event)
|
|
|
|
{
|
2011-10-08 22:03:44 +02:00
|
|
|
return P.p.shouldLetFactionsHandleThisChat(event);
|
2011-10-05 12:13:54 +02:00
|
|
|
}
|
|
|
|
public String modifyMessage(PlayerChatEvent event, Player target, String message)
|
|
|
|
{
|
2011-10-08 22:03:44 +02:00
|
|
|
return message.replace("{FACTION}", P.p.getPlayerFactionTagRelation(event.getPlayer(), target)).replace("{FACTION_TITLE}", P.p.getPlayerTitle(event.getPlayer()));
|
2011-10-05 12:13:54 +02:00
|
|
|
}
|
|
|
|
});
|
2011-10-08 22:03:44 +02:00
|
|
|
P.p.log("Found and will integrate chat with "+essChat.getDescription().getFullName());
|
2011-10-05 12:13:54 +02:00
|
|
|
}
|
2011-10-08 22:03:44 +02:00
|
|
|
catch (NoSuchMethodError ex)
|
|
|
|
{
|
2011-10-05 12:13:54 +02:00
|
|
|
essChat = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-08 22:03:44 +02:00
|
|
|
public static void unhookChat()
|
|
|
|
{
|
|
|
|
if (essChat != null)
|
|
|
|
{
|
2011-10-05 12:13:54 +02:00
|
|
|
essChat.removeEssentialsChatListener("Factions");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|