Modernizing the Herochat integration, it may still be outdated with newer Herochat versions though.

This commit is contained in:
Olof Larsson 2013-04-18 15:40:58 +02:00
parent 5e481d4120
commit 1ee9f2bba3
4 changed files with 58 additions and 24 deletions

View File

@ -109,7 +109,7 @@ public class ConfServer extends SimpleConfig
// We offer a simple standard way to set the format // We offer a simple standard way to set the format
public static boolean chatSetFormat = false; public static boolean chatSetFormat = false;
public static EventPriority chatSetFormatAt = EventPriority.LOWEST; public static EventPriority chatSetFormatAt = EventPriority.LOWEST;
public static String chatSetFormatTo = "<§l{factions_roleprefix}§r{factions_relcolor}{factions_tag|rp}§f%1$s> %2$s"; public static String chatSetFormatTo = "<{factions_relcolor}§l{factions_roleprefix}§r{factions_relcolor}{factions_tag|rp}§f%1$s> %2$s";
// We offer a simple standard way to parse the chat tags // We offer a simple standard way to parse the chat tags
public static boolean chatParseTags = true; public static boolean chatParseTags = true;

View File

@ -19,11 +19,11 @@ import com.massivecraft.factions.chat.tag.ChatTagTag;
import com.massivecraft.factions.chat.tag.ChatTagTagforce; import com.massivecraft.factions.chat.tag.ChatTagTagforce;
import com.massivecraft.factions.chat.tag.ChatTagTitle; import com.massivecraft.factions.chat.tag.ChatTagTitle;
import com.massivecraft.factions.cmd.*; import com.massivecraft.factions.cmd.*;
import com.massivecraft.factions.integration.herochat.HerochatFeatures;
import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.integration.LWCFeatures; import com.massivecraft.factions.integration.LWCFeatures;
import com.massivecraft.factions.integration.SpoutFeatures; import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.factions.integration.Worldguard; import com.massivecraft.factions.integration.Worldguard;
import com.massivecraft.factions.integration.herochat.HerochatFeatures;
import com.massivecraft.factions.listeners.FactionsListenerChat; import com.massivecraft.factions.listeners.FactionsListenerChat;
import com.massivecraft.factions.listeners.TodoFactionsEntityListener; import com.massivecraft.factions.listeners.TodoFactionsEntityListener;
import com.massivecraft.factions.listeners.FactionsListenerExploit; import com.massivecraft.factions.listeners.FactionsListenerExploit;
@ -112,9 +112,10 @@ public class Factions extends MPlugin
ChatTagTitle.get().register(); ChatTagTitle.get().register();
// Integrate // Integrate
this.integrate(HerochatFeatures.get());
SpoutFeatures.setup(); SpoutFeatures.setup();
Econ.setup(); Econ.setup();
HerochatFeatures.setup();
LWCFeatures.setup(); LWCFeatures.setup();
if (ConfServer.worldGuardChecking) if (ConfServer.worldGuardChecking)

View File

@ -1,19 +1,34 @@
package com.massivecraft.factions.integration.herochat; package com.massivecraft.factions.integration.herochat;
import org.bukkit.Bukkit; import com.dthielke.herochat.Herochat;
import org.bukkit.event.Listener; import com.massivecraft.mcore.integration.IntegrationFeaturesAbstract;
import org.bukkit.plugin.Plugin;
import com.massivecraft.factions.Factions; public class HerochatFeatures extends IntegrationFeaturesAbstract
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
public class HerochatFeatures implements Listener private static HerochatFeatures i = new HerochatFeatures();
public static HerochatFeatures get() { return i; }
private HerochatFeatures() { super("Herochat"); }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void activate()
{ {
public static void setup() Herochat.getChannelManager().addChannel(new FactionChannel());
Herochat.getChannelManager().addChannel(new AlliesChannel());
HerochatListener.get().activate();
}
@Override
public void deactivate()
{ {
Plugin plug = Bukkit.getServer().getPluginManager().getPlugin("Herochat"); HerochatListener.get().deactivate();
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");
} }
} }

View File

@ -1,28 +1,45 @@
package com.massivecraft.factions.integration.herochat; package com.massivecraft.factions.integration.herochat;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import com.dthielke.herochat.ChannelChatEvent; import com.dthielke.herochat.ChannelChatEvent;
import com.dthielke.herochat.Herochat;
import com.massivecraft.factions.ConfServer; import com.massivecraft.factions.ConfServer;
import com.massivecraft.factions.Factions; import com.massivecraft.factions.Factions;
import com.massivecraft.factions.chat.ChatFormatter; import com.massivecraft.factions.chat.ChatFormatter;
public class HerochatListener implements Listener 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; Bukkit.getPluginManager().registerEvents(this, Factions.get());
Herochat.getChannelManager().addChannel(new FactionChannel());
Herochat.getChannelManager().addChannel(new AlliesChannel());
} }
/** public void deactivate()
* Due to limitations in the new version of Herochat we can not offer relation colored tags. {
*/ HandlerList.unregisterAll(this);
}
// -------------------------------------------- //
// LISTENER
// -------------------------------------------- //
@EventHandler(priority = EventPriority.NORMAL) @EventHandler(priority = EventPriority.NORMAL)
public void onChannelChatEvent(ChannelChatEvent event) public void onChannelChatEvent(ChannelChatEvent event)
{ {
@ -34,4 +51,5 @@ public class HerochatListener implements Listener
format = ChatFormatter.format(format, event.getSender().getName(), null, null); format = ChatFormatter.format(format, event.getSender().getName(), null, null);
event.setFormat(format); event.setFormat(format);
} }
} }