2012-08-26 12:20:56 +02:00
|
|
|
package com.massivecraft.factions.integration.herochat;
|
|
|
|
|
2013-04-18 15:40:58 +02:00
|
|
|
import org.bukkit.Bukkit;
|
2012-08-26 12:20:56 +02:00
|
|
|
import org.bukkit.event.EventHandler;
|
|
|
|
import org.bukkit.event.EventPriority;
|
2013-04-18 15:40:58 +02:00
|
|
|
import org.bukkit.event.HandlerList;
|
2012-08-26 12:20:56 +02:00
|
|
|
import org.bukkit.event.Listener;
|
|
|
|
|
|
|
|
import com.dthielke.herochat.ChannelChatEvent;
|
2013-04-18 20:28:12 +02:00
|
|
|
import com.dthielke.herochat.Herochat;
|
2013-04-09 13:00:09 +02:00
|
|
|
import com.massivecraft.factions.Factions;
|
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;
|
2012-08-26 12:20:56 +02:00
|
|
|
|
2013-04-18 15:40:58 +02:00
|
|
|
|
2013-04-19 09:50:33 +02:00
|
|
|
public class HerochatEngine implements Listener
|
2012-08-26 12:20:56 +02:00
|
|
|
{
|
2013-04-18 15:40:58 +02:00
|
|
|
// -------------------------------------------- //
|
|
|
|
// INSTANCE & CONSTRUCT
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
2013-04-19 09:50:33 +02:00
|
|
|
private static HerochatEngine i = new HerochatEngine();
|
|
|
|
public static HerochatEngine get() { return i; }
|
|
|
|
private HerochatEngine() {}
|
2013-04-18 15:40:58 +02:00
|
|
|
|
|
|
|
// -------------------------------------------- //
|
|
|
|
// ACTIVATE & DEACTIVATE
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
|
|
|
public void activate()
|
2012-08-26 12:20:56 +02:00
|
|
|
{
|
2013-04-18 20:28:12 +02:00
|
|
|
Herochat.getChannelManager().addChannel(new FactionChannel());
|
|
|
|
Herochat.getChannelManager().addChannel(new AlliesChannel());
|
|
|
|
|
2013-04-18 15:40:58 +02:00
|
|
|
Bukkit.getPluginManager().registerEvents(this, Factions.get());
|
2012-08-26 12:20:56 +02:00
|
|
|
}
|
|
|
|
|
2013-04-18 15:40:58 +02:00
|
|
|
public void deactivate()
|
|
|
|
{
|
|
|
|
HandlerList.unregisterAll(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------- //
|
|
|
|
// 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();
|
|
|
|
format = format.replaceAll("&r", "§r");
|
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
|
|
|
}
|