Listeners should be MassiveCore engines.

This commit is contained in:
Olof Larsson 2014-10-08 06:24:37 +02:00
parent 48bda6a2df
commit 54e04fee88
5 changed files with 34 additions and 22 deletions

View File

@ -135,9 +135,9 @@ public class Factions extends MassivePlugin
this.outerCmdFactions.register(); this.outerCmdFactions.register();
// Setup Listeners // Setup Listeners
FactionsListenerMain.get().setup(); FactionsListenerMain.get().activate();
FactionsListenerChat.get().setup(); FactionsListenerChat.get().activate();
FactionsListenerExploit.get().setup(); FactionsListenerExploit.get().activate();
EngineIdUpdate.get().activate(); EngineIdUpdate.get().activate();
// TODO: This listener is a work in progress. // TODO: This listener is a work in progress.

View File

@ -42,7 +42,8 @@ public class MConf extends Entity<MConf>
if (!Factions.get().isDatabaseInitialized()) return this; if (!Factions.get().isDatabaseInitialized()) return this;
FactionsListenerChat.get().setup(); FactionsListenerChat.get().deactivate();
FactionsListenerChat.get().activate();
return this; return this;
} }

View File

@ -4,17 +4,18 @@ import org.bukkit.Bukkit;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.EventException; import org.bukkit.event.EventException;
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 org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.plugin.EventExecutor; import org.bukkit.plugin.EventExecutor;
import org.bukkit.plugin.Plugin;
import com.massivecraft.factions.Factions; import com.massivecraft.factions.Factions;
import com.massivecraft.factions.chat.ChatFormatter; import com.massivecraft.factions.chat.ChatFormatter;
import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.MConf;
import com.massivecraft.massivecore.EngineAbstract;
import com.massivecraft.massivecore.event.EventMassiveCorePlayerToRecipientChat; import com.massivecraft.massivecore.event.EventMassiveCorePlayerToRecipientChat;
public class FactionsListenerChat implements Listener public class FactionsListenerChat extends EngineAbstract
{ {
// -------------------------------------------- // // -------------------------------------------- //
// INSTANCE & CONSTRUCT // INSTANCE & CONSTRUCT
@ -24,12 +25,19 @@ public class FactionsListenerChat implements Listener
public static FactionsListenerChat get() { return i; } public static FactionsListenerChat get() { return i; }
// -------------------------------------------- // // -------------------------------------------- //
// SETUP // OVERRIDE
// -------------------------------------------- // // -------------------------------------------- //
public void setup() @Override
public Plugin getPlugin()
{ {
HandlerList.unregisterAll(this); return Factions.get();
}
@Override
public void activate()
{
super.activate();
if (MConf.get().chatSetFormat) if (MConf.get().chatSetFormat)
{ {
@ -45,7 +53,6 @@ public class FactionsListenerChat implements Listener
{ {
Bukkit.getPluginManager().registerEvent(EventMassiveCorePlayerToRecipientChat.class, this, EventPriority.NORMAL, new ParseRelcolorEventExecutor(), Factions.get(), true); Bukkit.getPluginManager().registerEvent(EventMassiveCorePlayerToRecipientChat.class, this, EventPriority.NORMAL, new ParseRelcolorEventExecutor(), Factions.get(), true);
} }
} }
// -------------------------------------------- // // -------------------------------------------- //

View File

@ -10,16 +10,16 @@ import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import com.massivecraft.factions.Factions; import com.massivecraft.factions.Factions;
import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.MConf;
import com.massivecraft.massivecore.EngineAbstract;
public class FactionsListenerExploit implements Listener public class FactionsListenerExploit extends EngineAbstract
{ {
// -------------------------------------------- // // -------------------------------------------- //
// INSTANCE & CONSTRUCT // INSTANCE & CONSTRUCT
@ -29,12 +29,13 @@ public class FactionsListenerExploit implements Listener
public static FactionsListenerExploit get() { return i; } public static FactionsListenerExploit get() { return i; }
// -------------------------------------------- // // -------------------------------------------- //
// SETUP // OVERRIDE
// -------------------------------------------- // // -------------------------------------------- //
public void setup() @Override
public Plugin getPlugin()
{ {
Bukkit.getPluginManager().registerEvents(this, Factions.get()); return Factions.get();
} }
// -------------------------------------------- // // -------------------------------------------- //
@ -135,4 +136,5 @@ public class FactionsListenerExploit implements Listener
} }
} }
} }
} }

View File

@ -22,7 +22,6 @@ import org.bukkit.entity.Wither;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockBurnEvent; import org.bukkit.event.block.BlockBurnEvent;
@ -56,6 +55,7 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.plugin.Plugin;
import org.bukkit.projectiles.ProjectileSource; import org.bukkit.projectiles.ProjectileSource;
import com.massivecraft.factions.Factions; import com.massivecraft.factions.Factions;
@ -72,6 +72,7 @@ import com.massivecraft.factions.event.EventFactionsPvpDisallowed;
import com.massivecraft.factions.event.EventFactionsPowerChange; import com.massivecraft.factions.event.EventFactionsPowerChange;
import com.massivecraft.factions.event.EventFactionsPowerChange.PowerChangeReason; import com.massivecraft.factions.event.EventFactionsPowerChange.PowerChangeReason;
import com.massivecraft.factions.util.VisualizeUtil; import com.massivecraft.factions.util.VisualizeUtil;
import com.massivecraft.massivecore.EngineAbstract;
import com.massivecraft.massivecore.event.EventMassiveCorePlayerLeave; import com.massivecraft.massivecore.event.EventMassiveCorePlayerLeave;
import com.massivecraft.massivecore.mixin.Mixin; import com.massivecraft.massivecore.mixin.Mixin;
import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.ps.PS;
@ -79,7 +80,7 @@ import com.massivecraft.massivecore.util.MUtil;
import com.massivecraft.massivecore.util.PlayerUtil; import com.massivecraft.massivecore.util.PlayerUtil;
import com.massivecraft.massivecore.util.Txt; import com.massivecraft.massivecore.util.Txt;
public class FactionsListenerMain implements Listener public class FactionsListenerMain extends EngineAbstract
{ {
// -------------------------------------------- // // -------------------------------------------- //
// INSTANCE & CONSTRUCT // INSTANCE & CONSTRUCT
@ -90,12 +91,13 @@ public class FactionsListenerMain implements Listener
public FactionsListenerMain() {} public FactionsListenerMain() {}
// -------------------------------------------- // // -------------------------------------------- //
// SETUP // OVERRIDE
// -------------------------------------------- // // -------------------------------------------- //
public void setup() @Override
public Plugin getPlugin()
{ {
Bukkit.getPluginManager().registerEvents(this, Factions.get()); return Factions.get();
} }
// -------------------------------------------- // // -------------------------------------------- //