You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.5 KiB
41 lines
1.5 KiB
package net.mcbat.LightningEvent.Listeners;
|
|
|
|
import net.mcbat.LightningEvent.LightningEvent;
|
|
|
|
import org.bukkit.event.Event;
|
|
import org.bukkit.event.Event.Priority;
|
|
import org.bukkit.event.server.PluginDisableEvent;
|
|
import org.bukkit.event.server.PluginEnableEvent;
|
|
import org.bukkit.event.server.ServerListener;
|
|
import org.bukkit.plugin.PluginManager;
|
|
|
|
import com.nijikokun.bukkit.Permissions.Permissions;
|
|
|
|
public class LightningEventServerListener extends ServerListener {
|
|
private final LightningEvent _plugin;
|
|
|
|
public LightningEventServerListener(LightningEvent plugin) {
|
|
_plugin = plugin;
|
|
}
|
|
|
|
public void registerEvents() {
|
|
PluginManager pm = _plugin.getServer().getPluginManager();
|
|
|
|
pm.registerEvent(Event.Type.PLUGIN_ENABLE, this, Priority.Monitor, _plugin);
|
|
pm.registerEvent(Event.Type.PLUGIN_DISABLE, this, Priority.Monitor, _plugin);
|
|
}
|
|
|
|
public void onPluginEnable(PluginEnableEvent event) {
|
|
if (_plugin.Permissions == null && event.getPlugin().getDescription().getName().equals("Permissions")) {
|
|
_plugin.Permissions = ((Permissions)event.getPlugin()).getHandler();
|
|
_plugin.getMinecraftLogger().info("[LightningEvent] hooked into Permissions/GroupManager.");
|
|
}
|
|
}
|
|
|
|
public void onPluginDisable(PluginDisableEvent event) {
|
|
if (_plugin.Permissions != null && event.getPlugin().getDescription().getName().equals("Permissions")) {
|
|
_plugin.Permissions = null;
|
|
_plugin.getMinecraftLogger().info("[LightningEvent] un-hooked from Permissions/GroupManager");
|
|
}
|
|
}
|
|
}
|
|
|