From 8e96a75b562d68e48210d111604ff351eb5a41df Mon Sep 17 00:00:00 2001 From: Brettflan Date: Tue, 7 Feb 2012 17:02:54 -0600 Subject: [PATCH] Update our MCore event handlers to use the newer Bukkit event system --- src/com/massivecraft/factions/zcore/MPlugin.java | 7 ++----- .../factions/zcore/MPluginSecretPlayerListener.java | 12 +++++++----- .../factions/zcore/MPluginSecretServerListener.java | 8 +++++--- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/com/massivecraft/factions/zcore/MPlugin.java b/src/com/massivecraft/factions/zcore/MPlugin.java index 3c525b3c..63d1a5cd 100644 --- a/src/com/massivecraft/factions/zcore/MPlugin.java +++ b/src/com/massivecraft/factions/zcore/MPlugin.java @@ -74,11 +74,8 @@ public abstract class MPlugin extends JavaPlugin // Create and register listeners this.mPluginSecretPlayerListener = new MPluginSecretPlayerListener(this); this.mPluginSecretServerListener = new MPluginSecretServerListener(this); - PluginManager pm = this.getServer().getPluginManager(); - pm.registerEvent(Event.Type.PLAYER_PRELOGIN, this.mPluginSecretPlayerListener, Event.Priority.Lowest, this); - pm.registerEvent(Event.Type.PLAYER_CHAT, this.mPluginSecretPlayerListener, Event.Priority.Low, this); - pm.registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESS, this.mPluginSecretPlayerListener, Event.Priority.Low, this); - pm.registerEvent(Event.Type.SERVER_COMMAND, this.mPluginSecretServerListener, Event.Priority.Lowest, this); + getServer().getPluginManager().registerEvents(this.mPluginSecretPlayerListener, this); + getServer().getPluginManager().registerEvents(this.mPluginSecretServerListener, this); // Register recurring tasks diff --git a/src/com/massivecraft/factions/zcore/MPluginSecretPlayerListener.java b/src/com/massivecraft/factions/zcore/MPluginSecretPlayerListener.java index 80787f97..1fab4ccd 100644 --- a/src/com/massivecraft/factions/zcore/MPluginSecretPlayerListener.java +++ b/src/com/massivecraft/factions/zcore/MPluginSecretPlayerListener.java @@ -1,9 +1,11 @@ package com.massivecraft.factions.zcore; import org.bukkit.Bukkit; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerListener; import org.bukkit.event.player.PlayerPreLoginEvent; import com.massivecraft.factions.zcore.persist.EM; @@ -11,7 +13,7 @@ import com.massivecraft.factions.zcore.persist.Entity; import com.massivecraft.factions.zcore.persist.EntityCollection; import com.massivecraft.factions.zcore.persist.PlayerEntityCollection; -public class MPluginSecretPlayerListener extends PlayerListener +public class MPluginSecretPlayerListener implements Listener { private MPlugin p; public MPluginSecretPlayerListener(MPlugin p) @@ -19,7 +21,7 @@ public class MPluginSecretPlayerListener extends PlayerListener this.p = p; } - @Override + @EventHandler(priority = EventPriority.LOW) public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { if (event.isCancelled()) return; @@ -31,7 +33,7 @@ public class MPluginSecretPlayerListener extends PlayerListener } } - @Override + @EventHandler(priority = EventPriority.LOW) public void onPlayerChat(PlayerChatEvent event) { if (event.isCancelled()) return; @@ -43,7 +45,7 @@ public class MPluginSecretPlayerListener extends PlayerListener } } - @Override + @EventHandler(priority = EventPriority.LOWEST) public void onPlayerPreLogin(PlayerPreLoginEvent event) { for (EntityCollection ecoll : EM.class2Entities.values()) diff --git a/src/com/massivecraft/factions/zcore/MPluginSecretServerListener.java b/src/com/massivecraft/factions/zcore/MPluginSecretServerListener.java index 678dc40f..3c144d50 100644 --- a/src/com/massivecraft/factions/zcore/MPluginSecretServerListener.java +++ b/src/com/massivecraft/factions/zcore/MPluginSecretServerListener.java @@ -2,10 +2,12 @@ package com.massivecraft.factions.zcore; import java.util.Map; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; import org.bukkit.event.server.ServerCommandEvent; -import org.bukkit.event.server.ServerListener; -public class MPluginSecretServerListener extends ServerListener +public class MPluginSecretServerListener implements Listener { private MPlugin p; private String refCommand; @@ -27,7 +29,7 @@ public class MPluginSecretServerListener extends ServerListener catch (ClassCastException ex) {} } - @Override + @EventHandler(priority = EventPriority.LOWEST) public void onServerCommand(ServerCommandEvent event) { if (event.getCommand().length() == 0) return;