org.bukkit.event.server.PluginDisableEvent Java Examples
The following examples show how to use
org.bukkit.event.server.PluginDisableEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ServerListener.java From AuthMeReloaded with GNU General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void onPluginDisable(PluginDisableEvent event) { final String pluginName = event.getPlugin().getName(); // Call the onPluginDisable method in the permissions manager permissionsManager.onPluginDisable(pluginName); if ("Essentials".equalsIgnoreCase(pluginName)) { pluginHookService.unhookEssentials(); logger.info("Essentials has been disabled: unhooking"); } else if ("CMI".equalsIgnoreCase(pluginName)) { pluginHookService.unhookCmi(); spawnLoader.unloadCmiSpawn(); logger.info("CMI has been disabled: unhooking"); } else if ("Multiverse-Core".equalsIgnoreCase(pluginName)) { pluginHookService.unhookMultiverse(); logger.info("Multiverse-Core has been disabled: unhooking"); } else if ("EssentialsSpawn".equalsIgnoreCase(pluginName)) { spawnLoader.unloadEssentialsSpawn(); logger.info("EssentialsSpawn has been disabled: unhooking"); } else if ("ProtocolLib".equalsIgnoreCase(pluginName)) { protocolLibService.disable(); logger.warning("ProtocolLib has been disabled, unhooking packet adapters!"); } }
Example #2
Source File: GuiListener.java From IF with The Unlicense | 6 votes |
/** * Handles the disabling of the plugin * * @param event the event fired * @since 0.5.19 */ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onPluginDisable(@NotNull PluginDisableEvent event) { Plugin thisPlugin = JavaPlugin.getProvidingPlugin(getClass()); if (event.getPlugin() != thisPlugin) { return; } int counter = 0; //callbacks might open GUIs, eg. in nested menus int maxCount = 10; while (!activeGuiInstances.isEmpty() && counter++ < maxCount) { for (Gui gui : new ArrayList<>(activeGuiInstances)) { for (HumanEntity viewer : gui.getViewers()) { viewer.closeInventory(); } } } if (counter == maxCount) { thisPlugin.getLogger().warning("Unable to close GUIs on plugin disable: they keep getting opened " + "(tried: " + maxCount + " times)"); } }
Example #3
Source File: Blackness.java From black with GNU General Public License v3.0 | 6 votes |
/** * this method handles every plugin disable event. * * @param event event to handle */ public void processPluginDisable(final PluginDisableEvent event) { if (!PLUGINQUEUE.peek().equals(event.getPlugin())) { synchronized (this) { PLUGINQUEUE.remove(event.getPlugin()); return; } } synchronized (this) { PLUGINQUEUE.poll(); } final Plugin nextPlugin = PLUGINQUEUE.peek(); if (nextPlugin != null && nextPlugin.isEnabled()) { registerListeners(nextPlugin); } }
Example #4
Source File: CivilianListener.java From Civs with GNU General Public License v3.0 | 6 votes |
@EventHandler public void onPluginDisable(PluginDisableEvent event) { if ("dynmap".equalsIgnoreCase(event.getPlugin().getName())) { DynmapHook.dynmapCommonAPI = null; } if ("MMOItems".equals(event.getPlugin().getName()) && !Bukkit.getPluginManager().isPluginEnabled("MMOItems")) { Civs.mmoItems = null; return; } if ("DiscordSRV".equals(event.getPlugin().getName()) && !Bukkit.getPluginManager().isPluginEnabled("DiscordSRV")) { Civs.discordSRV = null; return; } if (Constants.PLACEHOLDER_API.equals(event.getPlugin().getName())) { Civs.placeholderAPI = null; return; } }
Example #5
Source File: VaultBridge.java From BungeePerms with GNU General Public License v3.0 | 5 votes |
@Override public void disable() { Plugin plugin = Bukkit.getPluginManager().getPlugin("Vault"); if (plugin != null) { uninject(plugin); } PluginEnableEvent.getHandlerList().unregister(this); PluginDisableEvent.getHandlerList().unregister(this); }
Example #6
Source File: ItemFlagGui.java From RedProtect with GNU General Public License v3.0 | 5 votes |
@EventHandler void onPluginDisable(PluginDisableEvent event) { RedProtect.get().logger.debug(LogLevel.DEFAULT, "Is PluginDisableEvent event."); for (Player play : event.getPlugin().getServer().getOnlinePlayers()) { play.closeInventory(); } }
Example #7
Source File: FlagGui.java From RedProtect with GNU General Public License v3.0 | 5 votes |
@EventHandler void onPluginDisable(PluginDisableEvent event) { RedProtect.get().logger.debug(LogLevel.DEFAULT, "Is PluginDisableEvent event."); for (Player play : event.getPlugin().getServer().getOnlinePlayers()) { play.closeInventory(); } }
Example #8
Source File: HookManager.java From RandomTeleport with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onPluginDisable(PluginDisableEvent event) { PluginHook hook = hookMap.remove(event.getPlugin().getName()); if (hook instanceof Listener) { hook.unregisterEvents(); } }
Example #9
Source File: MenuListener.java From AmpMenus with GNU Lesser General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPluginDisable(PluginDisableEvent event) { if (event.getPlugin().equals(plugin)) { closeOpenMenus(); plugin = null; } }
Example #10
Source File: PlaceholderApiBridge.java From BungeePerms with GNU General Public License v3.0 | 5 votes |
@Override public void disable() { Plugin plugin = Bukkit.getPluginManager().getPlugin("PlaceholderAPI"); if (plugin != null) { // provider.unregister(); } PluginEnableEvent.getHandlerList().unregister(this); PluginDisableEvent.getHandlerList().unregister(this); }
Example #11
Source File: PlaceholderApiBridge.java From BungeePerms with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onPluginDisable(PluginDisableEvent e) { if (!e.getPlugin().getName().equalsIgnoreCase("PlaceholderAPI")) { return; } // provider.unregister(); }
Example #12
Source File: EssentialsBridge.java From BungeePerms with GNU General Public License v3.0 | 5 votes |
@Override public void disable() { Plugin plugin = Bukkit.getPluginManager().getPlugin("Essentials"); if (plugin != null) { uninject(plugin); } PluginEnableEvent.getHandlerList().unregister(this); PluginDisableEvent.getHandlerList().unregister(this); }
Example #13
Source File: EssentialsBridge.java From BungeePerms with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onPluginDisable(PluginDisableEvent e) { if (!e.getPlugin().getName().equalsIgnoreCase("Essentials")) { return; } uninject(e.getPlugin()); }
Example #14
Source File: Permission_BungeePerms.java From BungeePerms with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.MONITOR) public void onPluginDisable(PluginDisableEvent event) { if (perms != null) { if (event.getPlugin().getDescription().getName().equals("BungeePerms")) { perms = null; log.info(String.format("[%s][Permission] %s un-hooked.", plugin.getDescription().getName(), name)); } } }
Example #15
Source File: MobFlagGui.java From RedProtect with GNU General Public License v3.0 | 5 votes |
@EventHandler void onPluginDisable(PluginDisableEvent event) { RedProtect.get().logger.debug(LogLevel.DEFAULT, "Is PluginDisableEvent event."); for (Player play : event.getPlugin().getServer().getOnlinePlayers()) { play.closeInventory(); } }
Example #16
Source File: VaultBridge.java From BungeePerms with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onPluginDisable(PluginDisableEvent e) { if (!e.getPlugin().getName().equalsIgnoreCase("vault")) { return; } uninject(e.getPlugin()); }
Example #17
Source File: Chat_BungeePerms.java From BungeePerms with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.MONITOR) public void onPluginDisable(PluginDisableEvent event) { if (perms != null) { Plugin permPlugin = event.getPlugin(); if (permPlugin.getDescription().getName().equals("BungeePerms")) { perms = null; log.info(String.format("[%s][Chat] %s unhooked.", plugin.getDescription().getName(), name)); } } }
Example #18
Source File: WorldEditBridge.java From BungeePerms with GNU General Public License v3.0 | 5 votes |
@Override public void disable() { Plugin plugin = Bukkit.getPluginManager().getPlugin("WorldEdit"); if (plugin != null) { uninject(plugin); } PluginEnableEvent.getHandlerList().unregister(this); PluginDisableEvent.getHandlerList().unregister(this); }
Example #19
Source File: WorldEditBridge.java From BungeePerms with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onPluginDisable(PluginDisableEvent e) { if (!e.getPlugin().getName().equalsIgnoreCase("worldedit")) { return; } uninject(e.getPlugin()); }
Example #20
Source File: PluginListener.java From ScoreboardStats with MIT License | 5 votes |
/** * Check for disabled plugin to remove the associated replacer * * @param disableEvent the disable event */ @EventHandler public void onPluginDisable(PluginDisableEvent disableEvent) { //Remove the listener if the associated plugin was disabled Plugin disablePlugin = disableEvent.getPlugin(); replaceManager.unregisterAll(disablePlugin); }
Example #21
Source File: ServerListenerTest.java From AuthMeReloaded with GNU General Public License v3.0 | 5 votes |
private void checkDisableHandling(String pluginName, Runnable verifier) { PluginDisableEvent event = mockEventWithPluginName(PluginDisableEvent.class, pluginName); serverListener.onPluginDisable(event); verifier.run(); verify(permissionsManager).onPluginDisable(pluginName); verifyNoMoreInteractionsAndReset(); }
Example #22
Source File: PluginListener.java From Shopkeepers with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) void onPluginDisable(PluginDisableEvent event) { String pluginName = event.getPlugin().getName(); if (pluginName.equals(CitizensHandler.PLUGIN_NAME)) { CitizensHandler.disable(); } }
Example #23
Source File: EntityAPICore.java From EntityAPI with GNU Lesser General Public License v3.0 | 5 votes |
@EventHandler protected void onPluginDisable(PluginDisableEvent event) { if (hasEntityManager(event.getPlugin())) { EntityManager entityManager = getManagerFor(event.getPlugin()); entityManager.despawnAll(DespawnReason.PLUGIN_DISABLE); } }
Example #24
Source File: BukkitTaskChainFactory.java From TaskChain with MIT License | 5 votes |
@Override public void registerShutdownHandler(TaskChainFactory factory) { Bukkit.getPluginManager().registerEvents(new Listener() { @EventHandler public void onPluginDisable(PluginDisableEvent event) { if (event.getPlugin().equals(plugin)) { factory.shutdown(60, TimeUnit.SECONDS); } } }, plugin); }
Example #25
Source File: RuntimePluginLoader.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
public boolean togglePlugin(Plugin plugin, boolean on) { if (plugin.isEnabled() == on) return true; try { final Field enabled = JavaPlugin.class.getDeclaredField("isEnabled"); enabled.setAccessible(true); if (on) { enabled.setBoolean(plugin, true); plugin.onEnable(); } else { plugin.onDisable(); enabled.setBoolean(plugin, false); } final PluginEvent event = on ? new PluginEnableEvent(plugin) : new PluginDisableEvent(plugin); server.getPluginManager().callEvent(event); return true; } catch (NoSuchFieldException | IllegalAccessException e) { server.getLogger().log(Level.SEVERE, "Could not toggle plugin state", e); } catch (Throwable t) { server .getLogger() .log( Level.WARNING, "Could not " + (on ? "load" : "unload") + " plugin " + plugin.getName(), t); } return false; }
Example #26
Source File: PlaceholderListener.java From PlaceholderAPI with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.HIGH) public void onPluginUnload(PluginDisableEvent e) { String n = e.getPlugin().getName(); if (n == null) { return; } if (n.equals(plugin.getName())) { return; } Map<String, PlaceholderHook> hooks = PlaceholderAPI.getPlaceholders(); for (Entry<String, PlaceholderHook> hook : hooks.entrySet()) { PlaceholderHook i = hook.getValue(); if (i instanceof PlaceholderExpansion) { PlaceholderExpansion ex = (PlaceholderExpansion) i; if (ex.getRequiredPlugin() == null) { continue; } if (ex.getRequiredPlugin().equalsIgnoreCase(n)) { if (PlaceholderAPI.unregisterExpansion(ex)) { plugin.getLogger().info("Unregistered placeholder expansion: " + ex.getIdentifier()); } } } } }
Example #27
Source File: LWCServerListener.java From Modern-LWC with MIT License | 5 votes |
@EventHandler public void onPluginDisable(PluginDisableEvent event) { if (!LWC.ENABLED) { return; } Plugin disabled = event.getPlugin(); // Removes any modules registered by the disabled plugin plugin.getLWC().getModuleLoader().removeModules(disabled); }
Example #28
Source File: BukkitDB.java From db with MIT License | 5 votes |
public static Database createHikariDatabase(Plugin plugin, PooledDatabaseOptions options, boolean setGlobal) { HikariPooledDatabase db = new HikariPooledDatabase(options); if (setGlobal) { DB.setGlobalDatabase(db); } plugin.getServer().getPluginManager().registerEvents(new Listener() { @EventHandler(ignoreCancelled = true) public void onPluginDisable(PluginDisableEvent event) { if (event.getPlugin() == plugin) { db.close(); } } }, plugin); return db; }
Example #29
Source File: PluginHookMgr.java From SuperVanish with Mozilla Public License 2.0 | 5 votes |
@EventHandler public void onPluginDisable(PluginDisableEvent e) { Plugin plugin = e.getPlugin(); PluginHook hook = getActiveHook(plugin); if (hook == null) return; try { hook.onPluginDisable(plugin); } catch (Exception e1) { this.plugin.logException(new InvalidPluginHookException(e1)); } hook.setPlugin(null); activeHooks.remove(hook); }
Example #30
Source File: ItemMenuListener.java From AnnihilationPro with MIT License | 5 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPluginDisable(PluginDisableEvent event) { if (event.getPlugin().equals(plugin)) { closeOpenMenus(); plugin = null; } }