mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2025-01-11 18:37:35 +01:00
Created plugin listener
This commit is contained in:
parent
66365d6cf9
commit
5df1dc2dfb
@ -11,6 +11,7 @@ import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import fr.xephi.authme.listener.*;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@ -47,13 +48,6 @@ import fr.xephi.authme.datasource.MySQL;
|
||||
import fr.xephi.authme.datasource.SQLite;
|
||||
import fr.xephi.authme.hooks.BungeeCordMessage;
|
||||
import fr.xephi.authme.hooks.EssSpawn;
|
||||
import fr.xephi.authme.listener.AuthMeBlockListener;
|
||||
import fr.xephi.authme.listener.AuthMeEntityListener;
|
||||
import fr.xephi.authme.listener.AuthMeInventoryPacketAdapter;
|
||||
import fr.xephi.authme.listener.AuthMePlayerListener;
|
||||
import fr.xephi.authme.listener.AuthMePlayerListener16;
|
||||
import fr.xephi.authme.listener.AuthMePlayerListener18;
|
||||
import fr.xephi.authme.listener.AuthMeServerListener;
|
||||
import fr.xephi.authme.modules.ModuleManager;
|
||||
import fr.xephi.authme.process.Management;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
@ -335,6 +329,7 @@ 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);
|
||||
|
@ -0,0 +1,66 @@
|
||||
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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by Tim on 20-11-2015.
|
||||
*/
|
||||
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
|
||||
Core.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 Dungeon Maze itself
|
||||
if(plugin.equals(DungeonMaze.instance))
|
||||
return;
|
||||
|
||||
// Call the onPluginDisable method in the permissions manager
|
||||
Core.getPermissionsManager().onPluginDisable(event);
|
||||
|
||||
// Check if this plugin is hooked in to Dungeon Maze
|
||||
if(Core.getApiController().isHooked(plugin))
|
||||
// Unhook the plugin from Dungeon Maze and unregister it's API sessions
|
||||
Core.getApiController().unhookPlugin(plugin);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user