2012-08-26 12:20:56 +02:00
|
|
|
package com.massivecraft.factions.integration.herochat;
|
|
|
|
|
|
|
|
import org.bukkit.event.EventHandler;
|
|
|
|
import org.bukkit.event.EventPriority;
|
|
|
|
import com.dthielke.herochat.ChannelChatEvent;
|
2013-04-18 20:28:12 +02:00
|
|
|
import com.dthielke.herochat.Herochat;
|
2013-04-18 14:57:56 +02:00
|
|
|
import com.massivecraft.factions.chat.ChatFormatter;
|
2013-04-22 09:51:19 +02:00
|
|
|
import com.massivecraft.factions.entity.MConf;
|
2016-02-25 22:28:09 +01:00
|
|
|
import com.massivecraft.massivecore.Engine;
|
2012-08-26 12:20:56 +02:00
|
|
|
|
2016-02-25 22:28:09 +01:00
|
|
|
public class EngineHerochat extends Engine
|
2012-08-26 12:20:56 +02:00
|
|
|
{
|
2013-04-18 15:40:58 +02:00
|
|
|
// -------------------------------------------- //
|
|
|
|
// INSTANCE & CONSTRUCT
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
2014-06-04 14:02:23 +02:00
|
|
|
private static EngineHerochat i = new EngineHerochat();
|
|
|
|
public static EngineHerochat get() { return i; }
|
2013-04-18 15:40:58 +02:00
|
|
|
|
|
|
|
// -------------------------------------------- //
|
|
|
|
// ACTIVATE & DEACTIVATE
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
2016-02-25 22:28:09 +01:00
|
|
|
@Override
|
|
|
|
public void setActiveInner(boolean active)
|
2012-08-26 12:20:56 +02:00
|
|
|
{
|
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());
|
2013-04-18 15:40:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------- //
|
|
|
|
// LISTENER
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
2012-08-26 12:20:56 +02:00
|
|
|
@EventHandler(priority = EventPriority.NORMAL)
|
|
|
|
public void onChannelChatEvent(ChannelChatEvent event)
|
|
|
|
{
|
|
|
|
// Should we even parse?
|
2013-04-22 09:51:19 +02:00
|
|
|
if ( ! MConf.get().chatParseTags) return;
|
2012-08-26 12:20:56 +02:00
|
|
|
|
|
|
|
String format = event.getFormat();
|
2013-06-27 11:03:08 +02:00
|
|
|
|
|
|
|
// 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);
|
2013-04-18 14:57:56 +02:00
|
|
|
event.setFormat(format);
|
2012-08-26 12:20:56 +02:00
|
|
|
}
|
2013-04-18 15:40:58 +02:00
|
|
|
|
2012-08-26 12:20:56 +02:00
|
|
|
}
|