From 6b3f19f8577292eb1a073b23ef00b9dc28a2caa4 Mon Sep 17 00:00:00 2001 From: zml2008 Date: Wed, 7 Sep 2011 17:56:23 -0700 Subject: [PATCH] Minor cleanup of WEPIF constructors --- .../bukkit/migration/PermissionsResolverManager.java | 10 ++++++++++ .../migration/PermissionsResolverServerListener.java | 8 +++++++- .../com/sk89q/worldedit/bukkit/WorldEditPlugin.java | 9 ++++----- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/sk89q/bukkit/migration/PermissionsResolverManager.java b/src/main/java/com/sk89q/bukkit/migration/PermissionsResolverManager.java index 14690dd6b..731aed068 100644 --- a/src/main/java/com/sk89q/bukkit/migration/PermissionsResolverManager.java +++ b/src/main/java/com/sk89q/bukkit/migration/PermissionsResolverManager.java @@ -58,6 +58,7 @@ public class PermissionsResolverManager implements PermissionsResolver { private Logger logger; protected boolean ignoreNijiPermsBridges; + @Deprecated public PermissionsResolverManager(Configuration config, Server server, String name, Logger logger) { this.server = server; this.name = name; @@ -65,6 +66,15 @@ public class PermissionsResolverManager implements PermissionsResolver { loadConfig(new File("wepif.yml")); // TODO: config migration, maybe findResolver(); } + + public PermissionsResolverManager(Plugin plugin, String name, Logger logger) { + this.server = plugin.getServer(); + this.name = name; + this.logger = logger; + new PermissionsResolverServerListener(this, plugin); + loadConfig(new File("wepif.yml")); // TODO: config migration, maybe + findResolver(); + } public void findResolver() { if (tryPluginPermissionsResolver()) return; if (tryNijiPermissions()) return; diff --git a/src/main/java/com/sk89q/bukkit/migration/PermissionsResolverServerListener.java b/src/main/java/com/sk89q/bukkit/migration/PermissionsResolverServerListener.java index 3fccc3b5b..cba3427de 100644 --- a/src/main/java/com/sk89q/bukkit/migration/PermissionsResolverServerListener.java +++ b/src/main/java/com/sk89q/bukkit/migration/PermissionsResolverServerListener.java @@ -28,10 +28,16 @@ import org.bukkit.plugin.Plugin; public class PermissionsResolverServerListener extends ServerListener { private PermissionsResolverManager manager; - + + @Deprecated public PermissionsResolverServerListener(PermissionsResolverManager manager) { this.manager = manager; } + + public PermissionsResolverServerListener(PermissionsResolverManager manager, Plugin plugin) { + this.manager = manager; + register(plugin); + } /** * Called when a plugin is enabled diff --git a/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java index 245abf33f..065b36989 100644 --- a/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java +++ b/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java @@ -87,8 +87,7 @@ public class WorldEditPlugin extends JavaPlugin { // Set up configuration and such, including the permissions // resolver config = new BukkitConfiguration(getConfiguration(), logger); - perms = new PermissionsResolverManager( - getConfiguration(), getServer(), "WorldEdit", logger); + perms = new PermissionsResolverManager(this, "WorldEdit", logger); // Load the configuration loadConfiguration(); @@ -138,13 +137,13 @@ public class WorldEditPlugin extends JavaPlugin { new WorldEditCriticalPlayerListener(this); // The permissions resolver has some hooks of its own - (new PermissionsResolverServerListener(perms)).register(this); + new PermissionsResolverServerListener(perms, this); } /** * Register an event. * - * @param type + * @param typeName * @param listener * @param priority */ @@ -160,7 +159,7 @@ public class WorldEditPlugin extends JavaPlugin { /** * Register an event at normal priority. * - * @param type + * @param typeName * @param listener */ public void registerEvent(String typeName, Listener listener) {