54 lines
1.7 KiB
Java
Raw Normal View History

package com.massivecraft.factions.integration.herochat;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import com.dthielke.herochat.ChannelChatEvent;
import com.dthielke.herochat.Herochat;
import com.massivecraft.factions.chat.ChatFormatter;
import com.massivecraft.factions.entity.MConf;
2016-02-25 22:28:09 +01:00
import com.massivecraft.massivecore.Engine;
2016-02-25 22:28:09 +01:00
public class EngineHerochat extends Engine
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
2014-06-04 14:02:23 +02:00
private static EngineHerochat i = new EngineHerochat();
public static EngineHerochat get() { return i; }
// -------------------------------------------- //
// ACTIVATE & DEACTIVATE
// -------------------------------------------- //
2016-02-25 22:28:09 +01:00
@Override
public void setActiveInner(boolean active)
{
2016-02-25 22:28:09 +01:00
if ( ! active) return;
2014-06-04 14:02:23 +02:00
Herochat.getChannelManager().addChannel(new ChannelFactionsFaction());
Herochat.getChannelManager().addChannel(new ChannelFactionsAllies());
}
// -------------------------------------------- //
// LISTENER
// -------------------------------------------- //
@EventHandler(priority = EventPriority.NORMAL)
public void onChannelChatEvent(ChannelChatEvent event)
{
// Should we even parse?
if ( ! MConf.get().chatParseTags) return;
String format = event.getFormat();
// We trigger a replace of HeroChats tag {default} here
// This way we can replace faction tags hidden withing {default} as well.
format = format.replace("{default}", event.getChannel().getFormatSupplier().getStandardFormat());
2013-04-22 13:03:21 +02:00
2013-04-25 13:25:15 +02:00
format = ChatFormatter.format(format, event.getSender().getPlayer(), null);
event.setFormat(format);
}
}