diff --git a/src/main/java/fr/xephi/authme/listener/AuthMeServerListener.java b/src/main/java/fr/xephi/authme/listener/AuthMeServerListener.java index 0e3162b89..b627ed6d6 100644 --- a/src/main/java/fr/xephi/authme/listener/AuthMeServerListener.java +++ b/src/main/java/fr/xephi/authme/listener/AuthMeServerListener.java @@ -55,10 +55,11 @@ public class AuthMeServerListener implements Listener { return; } - // Call the onPluginDisable method in the permissions manager - permissionsManager.onPluginDisable(event); - final String pluginName = event.getPlugin().getName(); + + // Call the onPluginDisable method in the permissions manager + permissionsManager.onPluginDisable(pluginName); + if ("Essentials".equalsIgnoreCase(pluginName)) { pluginHooks.unhookEssentials(); ConsoleLogger.info("Essentials has been disabled: unhooking"); @@ -88,10 +89,11 @@ public class AuthMeServerListener implements Listener { return; } - // Call the onPluginEnable method in the permissions manager - permissionsManager.onPluginEnable(event); - final String pluginName = event.getPlugin().getName(); + + // Call the onPluginEnable method in the permissions manager + permissionsManager.onPluginEnable(pluginName); + if ("Essentials".equalsIgnoreCase(pluginName)) { pluginHooks.tryHookToEssentials(); } else if ("Multiverse-Core".equalsIgnoreCase(pluginName)) { diff --git a/src/main/java/fr/xephi/authme/permission/PermissionsManager.java b/src/main/java/fr/xephi/authme/permission/PermissionsManager.java index 072e82c5c..8094a6b4a 100644 --- a/src/main/java/fr/xephi/authme/permission/PermissionsManager.java +++ b/src/main/java/fr/xephi/authme/permission/PermissionsManager.java @@ -47,11 +47,7 @@ public class PermissionsManager { */ private final Server server; private final PluginManager pluginManager; - /** - * Type of permissions system that is currently used. - * Null if no permissions system is hooked and/or used. - */ - private PermissionsSystemType permsType = null; + /** * The permission handler that is currently in use. * Null if no permission system is hooked. @@ -79,15 +75,6 @@ public class PermissionsManager { return handler != null; } - /** - * Return the permissions system where the permissions manager is currently hooked into. - * - * @return The name of the permissions system used. - */ - public PermissionsSystemType getSystem() { - return permsType; - } - /** * Setup and hook into the permissions systems. */ @@ -96,9 +83,6 @@ public class PermissionsManager { // Force-unhook from current hooked permissions systems unhook(); - // Reset used permissions system type flag - permsType = null; - // Loop through all the available permissions system types for (PermissionsSystemType type : PermissionsSystemType.values()) { // Try to find and hook the current plugin if available, print an error if failed @@ -173,9 +157,6 @@ public class PermissionsManager { default: } - // Set the hooked permissions system type - this.permsType = type; - // Show a success message ConsoleLogger.info("Hooked into " + type.getName() + "!"); @@ -197,7 +178,6 @@ public class PermissionsManager { */ public void unhook() { // Reset the current used permissions system - this.permsType = null; this.handler = null; // Print a status message to the console @@ -209,25 +189,20 @@ public class PermissionsManager { * * @return True on success, false on failure. */ - public boolean reload() { + public void reload() { // Unhook all permission plugins unhook(); // Set up the permissions manager again, return the result setup(); - return true; } /** * Method called when a plugin is being enabled. * - * @param event Event instance. + * @param pluginName The name of the plugin being enabled. */ - public void onPluginEnable(PluginEnableEvent event) { - // Get the plugin and its name - Plugin plugin = event.getPlugin(); - String pluginName = plugin.getName(); - + public void onPluginEnable(String pluginName) { // Check if any known permissions system is enabling for (PermissionsSystemType permissionsSystemType : PermissionsSystemType.values()) { if (permissionsSystemType.isPermissionSystem(pluginName)) { @@ -241,14 +216,10 @@ public class PermissionsManager { /** * Method called when a plugin is being disabled. * - * @param event Event instance. + * @param pluginName The name of the plugin being disabled. */ - public void onPluginDisable(PluginDisableEvent event) { - // Get the plugin instance and name - Plugin plugin = event.getPlugin(); - String pluginName = plugin.getName(); - - // Is the WorldGuard plugin disabled + public void onPluginDisable(String pluginName) { + // Check if any known permission system is being disabled for (PermissionsSystemType permissionsSystemType : PermissionsSystemType.values()) { if (permissionsSystemType.isPermissionSystem(pluginName)) { ConsoleLogger.info(pluginName + " plugin disabled, updating hooks!");