From 745716426f8fbc6fa261887921f0efdf2193e959 Mon Sep 17 00:00:00 2001 From: zml2008 Date: Mon, 5 Dec 2011 19:48:14 -0800 Subject: [PATCH] Removed some unnecessary checks and fixed compatibility with CraftBook and other plugins that load() before registering the server listener --- .../migration/PermissionsResolverManager.java | 17 +++++++---------- .../PermissionsResolverServerListener.java | 4 +--- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/sk89q/bukkit/migration/PermissionsResolverManager.java b/src/main/java/com/sk89q/bukkit/migration/PermissionsResolverManager.java index b8943fb3d..571b003d6 100644 --- a/src/main/java/com/sk89q/bukkit/migration/PermissionsResolverManager.java +++ b/src/main/java/com/sk89q/bukkit/migration/PermissionsResolverManager.java @@ -21,21 +21,19 @@ package com.sk89q.bukkit.migration; import java.util.logging.Logger; +import com.sk89q.wepif.WEPIFRuntimeException; import org.bukkit.Server; import org.bukkit.plugin.Plugin; @Deprecated public class PermissionsResolverManager implements PermissionsProvider { - private static boolean setUp; @Deprecated public PermissionsResolverManager(org.bukkit.util.config.Configuration config, Server server, String name, Logger logger) {} @Deprecated public PermissionsResolverManager(Plugin plugin, String name, Logger logger) { - if (!setUp) { - setUp(plugin); - } + setUp(plugin); } @Deprecated @@ -50,7 +48,11 @@ public class PermissionsResolverManager implements PermissionsProvider { @Deprecated public void load() { + try { getRealResolver().load(); + } catch (WEPIFRuntimeException ignore) { + // Some plugins do this very early in the initialization process + } } public boolean hasPermission(String name, String permission) { @@ -72,17 +74,12 @@ public class PermissionsResolverManager implements PermissionsProvider { public String getDetectionMessage() { return getRealResolver().getDetectionMessage(); } - - boolean isSetUp() { - return setUp; - } void setUp(Plugin plugin) { com.sk89q.wepif.PermissionsResolverManager.initialize(plugin); - setUp = true; } - public com.sk89q.wepif.PermissionsResolverManager getRealResolver() { + private com.sk89q.wepif.PermissionsResolverManager getRealResolver() { return com.sk89q.wepif.PermissionsResolverManager.getInstance(); } diff --git a/src/main/java/com/sk89q/bukkit/migration/PermissionsResolverServerListener.java b/src/main/java/com/sk89q/bukkit/migration/PermissionsResolverServerListener.java index 46ec5186f..693cd44cc 100644 --- a/src/main/java/com/sk89q/bukkit/migration/PermissionsResolverServerListener.java +++ b/src/main/java/com/sk89q/bukkit/migration/PermissionsResolverServerListener.java @@ -39,9 +39,7 @@ public class PermissionsResolverServerListener extends ServerListener { @Deprecated public void register(Plugin plugin) { - if (!manager.isSetUp()) { - manager.setUp(plugin); - } + manager.setUp(plugin); } }