From 4e4a5a02c9d15ebc083c1408e54a86c3f0f4df06 Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Wed, 18 Jan 2012 17:50:07 +0100 Subject: [PATCH] Updated the remaining Listeners to the new event system. --- .../sk89q/bukkit/util/CommandRegistration.java | 4 +--- .../util/FallbackRegistrationListener.java | 7 ++++--- .../sk89q/wepif/PermissionsResolverManager.java | 16 ++++++---------- .../sk89q/worldedit/bukkit/WorldEditPlugin.java | 3 --- 4 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/sk89q/bukkit/util/CommandRegistration.java b/src/main/java/com/sk89q/bukkit/util/CommandRegistration.java index 89357f51f..4d43ef358 100644 --- a/src/main/java/com/sk89q/bukkit/util/CommandRegistration.java +++ b/src/main/java/com/sk89q/bukkit/util/CommandRegistration.java @@ -30,7 +30,6 @@ import org.bukkit.Bukkit; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandMap; import org.bukkit.command.SimpleCommandMap; -import org.bukkit.event.Event; import org.bukkit.plugin.Plugin; /** @@ -71,8 +70,7 @@ public class CommandRegistration { Bukkit.getServer().getLogger().severe(plugin.getDescription().getName() + ": Could not retrieve server CommandMap, using fallback instead! Please report to http://redmine.sk89q.com"); fallbackCommands = commandMap = new SimpleCommandMap(Bukkit.getServer()); - Bukkit.getServer().getPluginManager().registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESS, - new FallbackRegistrationListener(fallbackCommands), Event.Priority.Normal, plugin); + Bukkit.getServer().getPluginManager().registerEvents(new FallbackRegistrationListener(fallbackCommands), plugin); } } return commandMap; diff --git a/src/main/java/com/sk89q/bukkit/util/FallbackRegistrationListener.java b/src/main/java/com/sk89q/bukkit/util/FallbackRegistrationListener.java index 14725b172..5fc2a6a7b 100644 --- a/src/main/java/com/sk89q/bukkit/util/FallbackRegistrationListener.java +++ b/src/main/java/com/sk89q/bukkit/util/FallbackRegistrationListener.java @@ -19,13 +19,14 @@ package com.sk89q.bukkit.util; import org.bukkit.command.CommandMap; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerListener; /** * @author zml2008 */ -public class FallbackRegistrationListener extends PlayerListener { +public class FallbackRegistrationListener implements Listener { private final CommandMap commandRegistration; @@ -33,7 +34,7 @@ public class FallbackRegistrationListener extends PlayerListener { this.commandRegistration = commandRegistration; } - @Override + @EventHandler(event = PlayerCommandPreprocessEvent.class) public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { if (event.isCancelled()) { return; diff --git a/src/main/java/com/sk89q/wepif/PermissionsResolverManager.java b/src/main/java/com/sk89q/wepif/PermissionsResolverManager.java index 96c2f2b61..ce009a476 100644 --- a/src/main/java/com/sk89q/wepif/PermissionsResolverManager.java +++ b/src/main/java/com/sk89q/wepif/PermissionsResolverManager.java @@ -23,7 +23,7 @@ import com.sk89q.util.yaml.YAMLFormat; import com.sk89q.util.yaml.YAMLProcessor; import org.bukkit.OfflinePlayer; import org.bukkit.Server; -import org.bukkit.event.Event; +import org.bukkit.event.EventHandler; import org.bukkit.event.server.PluginDisableEvent; import org.bukkit.event.server.PluginEnableEvent; import org.bukkit.plugin.Plugin; @@ -260,9 +260,8 @@ public class PermissionsResolverManager implements PermissionsResolver { private static final long serialVersionUID = 7044832912491608706L; } - class ServerListener extends org.bukkit.event.server.ServerListener { - - @Override + class ServerListener implements org.bukkit.event.Listener { + @EventHandler(event = PluginEnableEvent.class) public void onPluginEnable(PluginEnableEvent event) { Plugin plugin = event.getPlugin(); String name = plugin.getDescription().getName(); @@ -273,7 +272,7 @@ public class PermissionsResolverManager implements PermissionsResolver { } } - @Override + @EventHandler(event = PluginDisableEvent.class) public void onPluginDisable(PluginDisableEvent event) { String name = event.getPlugin().getDescription().getName(); @@ -282,12 +281,9 @@ public class PermissionsResolverManager implements PermissionsResolver { load(); } } - + void register(Plugin plugin) { - plugin.getServer().getPluginManager().registerEvent(Event.Type.PLUGIN_ENABLE, - this, Event.Priority.Normal, plugin); - plugin.getServer().getPluginManager().registerEvent(Event.Type.PLUGIN_DISABLE, - this, Event.Priority.Normal, plugin); + plugin.getServer().getPluginManager().registerEvents(this, plugin); } } diff --git a/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java index c4f4302e6..4403d497e 100644 --- a/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java +++ b/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java @@ -33,9 +33,6 @@ import com.sk89q.wepif.PermissionsResolverManager; import org.bukkit.World; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import org.bukkit.event.Event.Priority; -import org.bukkit.event.Event; -import org.bukkit.event.Listener; import org.bukkit.plugin.java.JavaPlugin; import com.sk89q.worldedit.*; import com.sk89q.worldedit.bags.BlockBag;