Modernizing the Herochat integration, it may still be outdated with newer Herochat versions though.
This commit is contained in:
@ -1,19 +1,34 @@
|
||||
package com.massivecraft.factions.integration.herochat;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import com.dthielke.herochat.Herochat;
|
||||
import com.massivecraft.mcore.integration.IntegrationFeaturesAbstract;
|
||||
|
||||
import com.massivecraft.factions.Factions;
|
||||
|
||||
public class HerochatFeatures implements Listener
|
||||
public class HerochatFeatures extends IntegrationFeaturesAbstract
|
||||
{
|
||||
public static void setup()
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static HerochatFeatures i = new HerochatFeatures();
|
||||
public static HerochatFeatures get() { return i; }
|
||||
private HerochatFeatures() { super("Herochat"); }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void activate()
|
||||
{
|
||||
Plugin plug = Bukkit.getServer().getPluginManager().getPlugin("Herochat");
|
||||
if (plug == null) return;
|
||||
if (!plug.getClass().getName().equals("com.dthielke.herochat.Herochat")) return;
|
||||
Bukkit.getPluginManager().registerEvents(new HerochatListener(Factions.get()), Factions.get());
|
||||
Factions.get().log("Integration with Herochat successful");
|
||||
Herochat.getChannelManager().addChannel(new FactionChannel());
|
||||
Herochat.getChannelManager().addChannel(new AlliesChannel());
|
||||
HerochatListener.get().activate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deactivate()
|
||||
{
|
||||
HerochatListener.get().deactivate();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,28 +1,45 @@
|
||||
package com.massivecraft.factions.integration.herochat;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.dthielke.herochat.ChannelChatEvent;
|
||||
import com.dthielke.herochat.Herochat;
|
||||
import com.massivecraft.factions.ConfServer;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.chat.ChatFormatter;
|
||||
|
||||
|
||||
public class HerochatListener implements Listener
|
||||
{
|
||||
Factions p;
|
||||
public HerochatListener(Factions p)
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static HerochatListener i = new HerochatListener();
|
||||
public static HerochatListener get() { return i; }
|
||||
private HerochatListener() {}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// ACTIVATE & DEACTIVATE
|
||||
// -------------------------------------------- //
|
||||
|
||||
public void activate()
|
||||
{
|
||||
this.p = p;
|
||||
Herochat.getChannelManager().addChannel(new FactionChannel());
|
||||
Herochat.getChannelManager().addChannel(new AlliesChannel());
|
||||
Bukkit.getPluginManager().registerEvents(this, Factions.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* Due to limitations in the new version of Herochat we can not offer relation colored tags.
|
||||
*/
|
||||
public void deactivate()
|
||||
{
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// LISTENER
|
||||
// -------------------------------------------- //
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onChannelChatEvent(ChannelChatEvent event)
|
||||
{
|
||||
@ -34,4 +51,5 @@ public class HerochatListener implements Listener
|
||||
format = ChatFormatter.format(format, event.getSender().getName(), null, null);
|
||||
event.setFormat(format);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user