Combined Plugin and Server listener, removed plugin listener

This commit is contained in:
Tim Visée 2015-11-21 02:33:59 +01:00
parent bd1f868c6d
commit 5ff9b7550e
3 changed files with 19 additions and 59 deletions

View File

@ -364,7 +364,6 @@ public class AuthMe extends JavaPlugin {
pm.registerEvents(new AuthMePlayerListener18(this), this);
} catch (ClassNotFoundException ignore) {
}
pm.registerEvents(new AuthMePluginListener(this), this);
pm.registerEvents(new AuthMeBlockListener(this), this);
pm.registerEvents(new AuthMeEntityListener(this), this);
pm.registerEvents(new AuthMeServerListener(this), this);

View File

@ -1,57 +0,0 @@
package fr.xephi.authme.listener;
import fr.xephi.authme.AuthMe;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.plugin.Plugin;
/**
*/
public class AuthMePluginListener implements Listener {
/** Plugin instance. */
public AuthMe instance;
/**
* Constructor.
*
* @param instance Main plugin instance.
*/
public AuthMePluginListener(AuthMe instance) {
this.instance = instance;
}
/**
* Called when a plugin is enabled.
*
* @param event Event reference.
*/
@EventHandler
public void onPluginEnable(PluginEnableEvent event) {
// Call the onPluginEnable method in the permissions manager
this.instance.getPermissionsManager().onPluginEnable(event);
}
/**
* Called when a plugin is disabled.
*
* @param event Event reference.
*/
@EventHandler
public void onPluginDisable(PluginDisableEvent event) {
// Get the plugin instance
Plugin plugin = event.getPlugin();
// Make sure the plugin instance isn't null
if(plugin == null)
return;
// Make sure it's not this plugin itself
if(plugin.equals(this.instance))
return;
// Call the onPluginDisable method in the permissions manager
this.instance.getPermissionsManager().onPluginDisable(event);
}
}

View File

@ -12,6 +12,7 @@ import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.settings.Messages;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.util.Utils;
import org.bukkit.plugin.Plugin;
/**
*/
@ -55,7 +56,21 @@ public class AuthMeServerListener implements Listener {
*/
@EventHandler(priority = EventPriority.HIGHEST)
public void onPluginDisable(PluginDisableEvent event) {
String pluginName = event.getPlugin().getName();
// Get the plugin instance
Plugin pluginInstance = event.getPlugin();
// Make sure the plugin instance isn't null
if(pluginInstance == null)
return;
// Make sure it's not this plugin itself
if(pluginInstance.equals(this.plugin))
return;
// Call the onPluginDisable method in the permissions manager
this.plugin.getPermissionsManager().onPluginDisable(event);
String pluginName = pluginInstance.getName();
if (pluginName.equalsIgnoreCase("Essentials")) {
plugin.ess = null;
ConsoleLogger.info("Essentials has been disabled, unhook!");
@ -91,6 +106,9 @@ public class AuthMeServerListener implements Listener {
*/
@EventHandler(priority = EventPriority.HIGHEST)
public void onPluginEnable(PluginEnableEvent event) {
// Call the onPluginEnable method in the permissions manager
this.plugin.getPermissionsManager().onPluginEnable(event);
String pluginName = event.getPlugin().getName();
if (pluginName.equalsIgnoreCase("Essentials") || pluginName.equalsIgnoreCase("EssentialsSpawn"))
plugin.checkEssentials();