From b938aa0be3fbe460821677240f982d21560ded4f Mon Sep 17 00:00:00 2001 From: zml2008 Date: Thu, 19 Apr 2012 21:44:57 -0700 Subject: [PATCH] Add isInitialized method to PermissionsResolverManager for an easy way to check if the PermissionsResolverManager has been initialized --- .../com/sk89q/wepif/PermissionsResolverManager.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/sk89q/wepif/PermissionsResolverManager.java b/src/main/java/com/sk89q/wepif/PermissionsResolverManager.java index dc172ccad..a2d51e502 100644 --- a/src/main/java/com/sk89q/wepif/PermissionsResolverManager.java +++ b/src/main/java/com/sk89q/wepif/PermissionsResolverManager.java @@ -64,13 +64,17 @@ public class PermissionsResolverManager implements PermissionsResolver { private static PermissionsResolverManager instance; public static void initialize(Plugin plugin) { - if (instance == null) { + if (!isInitialized()) { instance = new PermissionsResolverManager(plugin); } } + public static boolean isInitialized() { + return instance != null; + } + public static PermissionsResolverManager getInstance() { - if (instance == null) { + if (!isInitialized()) { throw new WEPIFRuntimeException("WEPIF has not yet been initialized!"); } return instance; @@ -214,7 +218,7 @@ public class PermissionsResolverManager implements PermissionsResolver { try { next = Class.forName(getClass().getPackage().getName() + "." + nextName); } catch (ClassNotFoundException e) {} - + if (next == null || !PermissionsResolver.class.isAssignableFrom(next)) { logger.warning("WEPIF: Invalid or unknown class found in enabled resolvers: " + nextName + ". Moving to disabled resolvers list."); @@ -278,7 +282,7 @@ public class PermissionsResolverManager implements PermissionsResolver { public void onPluginDisable(PluginDisableEvent event) { String name = event.getPlugin().getDescription().getName(); - if (event.getPlugin() instanceof PermissionsProvider + if (event.getPlugin() instanceof PermissionsProvider || "Permissions".equals(name) || "PermissionsEx".equals(name) || "bPermissions".equals(name)) { load();