3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-10 05:20:04 +01:00

Add isInitialized method to PermissionsResolverManager for an easy way to check if the PermissionsResolverManager has been initialized

Dieser Commit ist enthalten in:
zml2008 2012-04-19 21:44:57 -07:00
Ursprung cd64ca459d
Commit b938aa0be3

Datei anzeigen

@ -64,13 +64,17 @@ public class PermissionsResolverManager implements PermissionsResolver {
private static PermissionsResolverManager instance; private static PermissionsResolverManager instance;
public static void initialize(Plugin plugin) { public static void initialize(Plugin plugin) {
if (instance == null) { if (!isInitialized()) {
instance = new PermissionsResolverManager(plugin); instance = new PermissionsResolverManager(plugin);
} }
} }
public static boolean isInitialized() {
return instance != null;
}
public static PermissionsResolverManager getInstance() { public static PermissionsResolverManager getInstance() {
if (instance == null) { if (!isInitialized()) {
throw new WEPIFRuntimeException("WEPIF has not yet been initialized!"); throw new WEPIFRuntimeException("WEPIF has not yet been initialized!");
} }
return instance; return instance;
@ -214,7 +218,7 @@ public class PermissionsResolverManager implements PermissionsResolver {
try { try {
next = Class.forName(getClass().getPackage().getName() + "." + nextName); next = Class.forName(getClass().getPackage().getName() + "." + nextName);
} catch (ClassNotFoundException e) {} } catch (ClassNotFoundException e) {}
if (next == null || !PermissionsResolver.class.isAssignableFrom(next)) { if (next == null || !PermissionsResolver.class.isAssignableFrom(next)) {
logger.warning("WEPIF: Invalid or unknown class found in enabled resolvers: " logger.warning("WEPIF: Invalid or unknown class found in enabled resolvers: "
+ nextName + ". Moving to disabled resolvers list."); + nextName + ". Moving to disabled resolvers list.");
@ -278,7 +282,7 @@ public class PermissionsResolverManager implements PermissionsResolver {
public void onPluginDisable(PluginDisableEvent event) { public void onPluginDisable(PluginDisableEvent event) {
String name = event.getPlugin().getDescription().getName(); String name = event.getPlugin().getDescription().getName();
if (event.getPlugin() instanceof PermissionsProvider if (event.getPlugin() instanceof PermissionsProvider
|| "Permissions".equals(name) || "PermissionsEx".equals(name) || "Permissions".equals(name) || "PermissionsEx".equals(name)
|| "bPermissions".equals(name)) { || "bPermissions".equals(name)) {
load(); load();