Java 类org.bukkit.event.server.PluginDisableEvent 实例源码

项目:ExilePearl    文件:TestPluginManager.java   
private void loaderDisablePlugin(Plugin plugin) {
       if (plugin.isEnabled()) {
           plugin.getLogger().info("Disabling " + plugin.getDescription().getFullName());

           JavaPlugin jPlugin = (JavaPlugin) plugin;

           try {
            Field f = JavaPlugin.class.getDeclaredField("isEnabled");
            f.setAccessible(true);
            boolean enabled = f.getBoolean(jPlugin);
            if (enabled) {
                f.setBoolean(jPlugin, false);
                jPlugin.onDisable();
            }
           } catch (Throwable ex) {
               server.getLogger().log(Level.SEVERE, "Error occurred while disabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex);
           }

           server.getPluginManager().callEvent(new PluginDisableEvent(plugin));
       }
}
项目:MoreMobs    文件:TinyProtocol.java   
private void registerBukkitEvents() {
    listener = new Listener() {

        @EventHandler(priority = EventPriority.LOWEST)
        public final void onPlayerLogin(PlayerLoginEvent e) {
            if (closed)
                return;

            Channel channel = getChannel(e.getPlayer());

            if (!uninjectedChannels.contains(channel)) {
                injectPlayer(e.getPlayer());
            }
        }

        @EventHandler
        public final void onPluginDisable(PluginDisableEvent e) {
            if (e.getPlugin().equals(plugin)) {
                close();
            }
        }

    };

    plugin.getServer().getPluginManager().registerEvents(listener, plugin);
}
项目:-XclsX-TPAv3-XclsX-    文件:TinyProtocolAPI.java   
private void registerBukkitEvents() {
    listener = new Listener() {

        @EventHandler(priority = EventPriority.LOWEST)
        public final void onPlayerLogin(PlayerLoginEvent e) {
            if (closed)
                return;

            Channel channel = getChannel(e.getPlayer());

            if (!uninjectedChannels.contains(channel))
                injectPlayer(e.getPlayer());
        }

        @EventHandler
        public final void onPluginDisable(PluginDisableEvent e) {
            if (e.getPlugin().equals(plugin)) {
                close();
            }
        }

    };

    plugin.getServer().getPluginManager().registerEvents(listener, plugin);
}
项目:SignGUI    文件:TinyProtocol.java   
private void registerBukkitEvents() {
    listener = new Listener() {

        @EventHandler(priority = EventPriority.LOWEST)
        public final void onPlayerLogin(PlayerLoginEvent e) {
            if (closed)
                return;

            Channel channel = getChannel(e.getPlayer());

            if (!uninjectedChannels.contains(channel)) {
                injectPlayer(e.getPlayer());
            }
        }

        @EventHandler
        public final void onPluginDisable(PluginDisableEvent e) {
            if (e.getPlugin().equals(plugin)) {
                close();
            }
        }

    };

    plugin.getServer().getPluginManager().registerEvents(listener, plugin);
}
项目:-XclsX-TPAv2-XclsX-    文件:TinyProtocol.java   
private void registerBukkitEvents() {
    listener = new Listener() {

        @EventHandler(priority = EventPriority.LOWEST)
        public final void onPlayerLogin(PlayerLoginEvent e) {
            if (closed)
                return;

            Channel channel = getChannel(e.getPlayer());

            if (!uninjectedChannels.contains(channel)) {
                injectPlayer(e.getPlayer());
            }
        }

        @EventHandler
        public final void onPluginDisable(PluginDisableEvent e) {
            if (e.getPlugin().equals(plugin)) {
                close();
            }
        }

    };

    plugin.getServer().getPluginManager().registerEvents(listener, plugin);
}
项目:pploader    文件:PythonPluginLoader.java   
public void disablePlugin(Plugin plugin) {
    if (!(plugin instanceof PythonPlugin)) {
        throw new IllegalArgumentException("Plugin is not associated with this PluginLoader");
    }

    if (plugin.isEnabled()) {
        PythonPlugin pyPlugin = (PythonPlugin) plugin;

        try {
            pyPlugin.setEnabled(false);
        } catch (Throwable ex) {
            server.getLogger().log(Level.SEVERE,
                    "Error occurred while disabling " + plugin.getDescription().getFullName()
                            + " (Is it up to date?): " + ex.getMessage(),
                    ex);
        }

        server.getPluginManager().callEvent(new PluginDisableEvent(plugin));

        String pluginName = pyPlugin.getDescription().getName();
        if (loadedplugins.contains(pluginName))
            loadedplugins.remove(pluginName);
    }
}
项目:ZentrelaRPG    文件:TinyProtocol.java   
/**
 * Register bukkit events.
 */
private void registerBukkitEvents() {
    listener = new Listener() {

        //            @EventHandler(priority = EventPriority.LOWEST)
        //            public final void onPlayerLogin(PlayerLoginEvent e) {
        //                if (closed)
        //                    return;
        //
        //                Channel channel = getChannel(e.getPlayer());
        //
        //                // Don't inject players that have been explicitly uninjected
        //                if (!uninjectedChannels.contains(channel)) {
        //                    injectPlayer(e.getPlayer());
        //                }
        //            }

        @EventHandler
        public final void onPluginDisable(PluginDisableEvent e) {
            if (e.getPlugin().equals(plugin)) {
                close();
            }
        }

    };

    plugin.getServer().getPluginManager().registerEvents(listener, plugin);
}
项目:SmartInvs    文件:InventoryManager.java   
@EventHandler(priority = EventPriority.LOW)
public void onPluginDisable(PluginDisableEvent e) {
    new HashSet<>(inventories.entrySet()).forEach(entry -> {
        SmartInventory inv = entry.getValue();

        inv.getListeners().stream()
                .filter(listener -> listener.getType() == PluginDisableEvent.class)
                .forEach(listener -> ((InventoryListener<PluginDisableEvent>) listener).accept(e));

        inv.close(entry.getKey());
    });
}
项目:Kineticraft    文件:MechanicManager.java   
@EventHandler
public void onPluginDisable(PluginDisableEvent event) {
    if (event.getPlugin() != Core.getInstance()) // KCv4 isn't unloading.
        return;
    Core.logInfo("Shutting down...");
    getMechanics().forEach(Mechanic::onDisable); // Unload all mechanics.
}
项目:OpGuard    文件:PluginDisableHijack.java   
@EventHandler
public void on(PluginDisableEvent event)
{
    if (event.getPlugin() == api.getPlugin() && api.getConfig().canShutDownOnDisable())
    {
        Messenger.send("&c[&fOpGuard was disabled&c] Shutting server down.");
        Bukkit.shutdown();
    }
}
项目:TaskChain    文件:BukkitTaskChainFactory.java   
@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);
}
项目:GameBoxx    文件:Menu.java   
@EventHandler
private void pluginDisable(PluginDisableEvent event) {
    if (menus == null || menus.isEmpty()) {
        return;
    }
    List<Menu> menusClone = new ArrayList<Menu>(menus);
    for (Menu menu : menusClone) {
        if (menu.plugin == event.getPlugin()) {
            menu.destroyMenu();
        }
    }
}
项目:TinyProtocolAPI    文件:TabListener.java   
@EventHandler
void disable(PluginDisableEvent e)
{
    if(!e.getPlugin().getClass().equals(TinyProtocolAPI.class)) return;
    for(Player player : Bukkit.getServer().getOnlinePlayers())
        TabAPI.remove(TinyProtocolAPI.class, player);
}
项目:TinyProtocolAPI    文件:TabMap.java   
@EventHandler
void vb(PluginDisableEvent e)
{
    if(!e.getPlugin().getName().equals("TinyProtocolAPI")) return;
    for(Player a : e.getPlugin().getServer().getOnlinePlayers())
    {
        UUID b = a.getUniqueId();
        fa.sendAbstractPacket(a, get(b).mb());
    }
}
项目:Thermos-Bukkit    文件:JavaPluginLoader.java   
public void disablePlugin(Plugin plugin) {
    Validate.isTrue(plugin instanceof JavaPlugin, "Plugin is not associated with this PluginLoader");

    if (plugin.isEnabled()) {
        String message = String.format("Disabling %s", plugin.getDescription().getFullName());
        plugin.getLogger().info(message);

        server.getPluginManager().callEvent(new PluginDisableEvent(plugin));

        JavaPlugin jPlugin = (JavaPlugin) plugin;
        ClassLoader cloader = jPlugin.getClassLoader();

        try {
            jPlugin.setEnabled(false);
        } catch (Throwable ex) {
            server.getLogger().log(Level.SEVERE, "Error occurred while disabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex);
        }

        loaders.remove(jPlugin.getDescription().getName());

        if (cloader instanceof PluginClassLoader) {
            PluginClassLoader loader = (PluginClassLoader) cloader;
            Set<String> names = loader.getClasses();

            for (String name : names) {
                removeClass(name);
            }
        }
    }
}
项目:AnnihilationPro    文件:ItemMenuListener.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPluginDisable(PluginDisableEvent event)
{
    if (event.getPlugin().equals(plugin))
    {
        closeOpenMenus();
        plugin = null;
    }
}
项目:economy    文件:SubPluginLoader.java   
@Override
public void disablePlugin(Plugin plugin) {
    valid(plugin);
    if (plugin.isEnabled()) {
        plugin.getLogger().info("Disabling " + plugin.getDescription().getFullName());
        SubPlugin sub = (SubPlugin) plugin;
        try {
            sub.setEnabled(false);
        } catch (Exception e) {
            Bukkit.getLogger().log(Level.SEVERE, "Error occurred while disabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", e);
        }
        Fun.unload(sub);
        Bukkit.getPluginManager().callEvent(new PluginDisableEvent(plugin));
    }
}
项目:Steel    文件:PluginListener.java   
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(PluginDisableEvent event) {
    Minigame mg = SteelCore.getMinigames().get(event.getPlugin().getName());
    if (mg != null) {
        ImmutableList<Round> rounds = ImmutableList.copyOf(mg.getRounds());
        for (Round round : rounds) {
            round.end();
        }
    }
}
项目:CauldronGit    文件:JavaPluginLoader.java   
public void disablePlugin(Plugin plugin) {
    Validate.isTrue(plugin instanceof JavaPlugin, "Plugin is not associated with this PluginLoader");

    if (plugin.isEnabled()) {
        String message = String.format("Disabling %s", plugin.getDescription().getFullName());
        plugin.getLogger().info(message);

        server.getPluginManager().callEvent(new PluginDisableEvent(plugin));

        JavaPlugin jPlugin = (JavaPlugin) plugin;
        ClassLoader cloader = jPlugin.getClassLoader();

        try {
            jPlugin.setEnabled(false);
        } catch (Throwable ex) {
            server.getLogger().log(Level.SEVERE, "Error occurred while disabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex);
        }

        loaders.remove(jPlugin.getDescription().getName());

        if (cloader instanceof PluginClassLoader) {
            PluginClassLoader loader = (PluginClassLoader) cloader;
            Set<String> names = loader.getClasses();

            for (String name : names) {
                removeClass(name);
            }
        }
    }
}
项目:SuperVanish    文件:PluginHookMgr.java   
@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);
}
项目:RedProtect    文件:RPGui.java   
@EventHandler
void onPluginDisable(PluginDisableEvent event){
    RedProtect.get().logger.debug("Is PluginDisableEvent event.");
    for (Player play:event.getPlugin().getServer().getOnlinePlayers()){
        play.closeInventory();
    }
}
项目:vanillacraft    文件:DatabaseQueryManager.java   
@EventHandler
public void onDisable(PluginDisableEvent event)
{
    if(event.getPlugin().getName().equals(CoreFunctions.getInstance().getName()))
    {
        for(DisableableThread t : threads)
            t.disable();
    }
}
项目:gFeatures    文件:TinyProtocol.java   
/**
 * Register bukkit events.
 */
private void registerBukkitEvents() {
    listener = new Listener() {

        @EventHandler(priority = EventPriority.LOWEST)
        public final void onPlayerLogin(PlayerLoginEvent e) {
            if (closed)
                return;

            Channel channel = getChannel(e.getPlayer());

            // Don't inject players that have been explicitly uninjected
            if (!uninjectedChannels.contains(channel)) {
                injectPlayer(e.getPlayer());
            }
        }

        @EventHandler
        public final void onPluginDisable(PluginDisableEvent e) {
            if (e.getPlugin().equals(plugin)) {
                close();
            }
        }

    };

    plugin.getServer().getPluginManager().registerEvents(listener, plugin);
}
项目:SteakGUI    文件:MenuListener.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPluginDisable(PluginDisableEvent event) {
    if (event.getPlugin().equals(plugin)) {
        closeOpenMenus();
        plugin = null;
    }
}
项目:Magix-Plugin    文件:CommandHandler.java   
@EventHandler
public void pluginDisable(PluginDisableEvent event) {
    if (event.getPlugin().getName().equalsIgnoreCase("Magix")) {
        for (String name : this.playerToItemStack.keySet()) {
            Player player = Bukkit.getPlayerExact(name);

            if (player == null)
                continue;

            check(player, player.getItemInHand());
        }
    }
}
项目:AmpMenus    文件:MenuListener.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPluginDisable(PluginDisableEvent event) {
    if (event.getPlugin().equals(plugin)) {
        closeOpenMenus();
        plugin = null;
    }
}
项目:Cauldron    文件:JavaPluginLoader.java   
public void disablePlugin(Plugin plugin) {
    Validate.isTrue(plugin instanceof JavaPlugin, "Plugin is not associated with this PluginLoader");

    if (plugin.isEnabled()) {
        String message = String.format("Disabling %s", plugin.getDescription().getFullName());
        plugin.getLogger().info(message);

        server.getPluginManager().callEvent(new PluginDisableEvent(plugin));

        JavaPlugin jPlugin = (JavaPlugin) plugin;
        ClassLoader cloader = jPlugin.getClassLoader();

        try {
            jPlugin.setEnabled(false);
        } catch (Throwable ex) {
            server.getLogger().log(Level.SEVERE, "Error occurred while disabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex);
        }

        loaders.remove(jPlugin.getDescription().getName());

        if (cloader instanceof PluginClassLoader) {
            PluginClassLoader loader = (PluginClassLoader) cloader;
            Set<String> names = loader.getClasses();

            for (String name : names) {
                removeClass(name);
            }
        }
    }
}
项目:Cauldron    文件:JavaPluginLoader.java   
public void disablePlugin(Plugin plugin) {
    Validate.isTrue(plugin instanceof JavaPlugin, "Plugin is not associated with this PluginLoader");

    if (plugin.isEnabled()) {
        String message = String.format("Disabling %s", plugin.getDescription().getFullName());
        plugin.getLogger().info(message);

        server.getPluginManager().callEvent(new PluginDisableEvent(plugin));

        JavaPlugin jPlugin = (JavaPlugin) plugin;
        ClassLoader cloader = jPlugin.getClassLoader();

        try {
            jPlugin.setEnabled(false);
        } catch (Throwable ex) {
            server.getLogger().log(Level.SEVERE, "Error occurred while disabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex);
        }

        loaders.remove(jPlugin.getDescription().getName());

        if (cloader instanceof PluginClassLoader) {
            PluginClassLoader loader = (PluginClassLoader) cloader;
            Set<String> names = loader.getClasses();

            for (String name : names) {
                removeClass(name);
            }
        }
    }
}
项目:Cauldron    文件:JavaPluginLoader.java   
public void disablePlugin(Plugin plugin) {
    Validate.isTrue(plugin instanceof JavaPlugin, "Plugin is not associated with this PluginLoader");

    if (plugin.isEnabled()) {
        String message = String.format("Disabling %s", plugin.getDescription().getFullName());
        plugin.getLogger().info(message);

        server.getPluginManager().callEvent(new PluginDisableEvent(plugin));

        JavaPlugin jPlugin = (JavaPlugin) plugin;
        ClassLoader cloader = jPlugin.getClassLoader();

        try {
            jPlugin.setEnabled(false);
        } catch (Throwable ex) {
            server.getLogger().log(Level.SEVERE, "Error occurred while disabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex);
        }

        loaders.remove(jPlugin.getDescription().getName());

        if (cloader instanceof PluginClassLoader) {
            PluginClassLoader loader = (PluginClassLoader) cloader;
            Set<String> names = loader.getClasses();

            for (String name : names) {
                removeClass(name);
            }
        }
    }
}
项目:Stoa    文件:WorldGuardUtil.java   
@EventHandler(priority = EventPriority.MONITOR)
void onPluginDisable(PluginDisableEvent event) {
    if (!ENABLED || event.getPlugin().getName().equals("WorldGuard")) return;
    try {
        ENABLED = false;
    } catch (Exception ignored) {
    }
}
项目:SkinChanger    文件:EventListener.java   
@EventHandler
public void onPluginDisable(PluginDisableEvent event) {
    if (event.getPlugin().getDescription().getName().equals("ProtocolLib") && Main.getInstance().isPluginEnabled()) {
        Main.getInstance().disablePlugin();
        Main.getInstance().setPluginEnabled(false);
    }
}
项目:RoyalEconomy    文件:VaultConnector.java   
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(final PluginDisableEvent event) {
    if (this.economy.economy != null) {
        if (event.getPlugin().getDescription().getName().equals("RoyalEconomy")) {
            this.economy.economy = null;
            VaultConnector.this.plugin.getLogger().info("Removed Vault hook.");
        }
    }
}
项目:Almura-API    文件:JavaPluginLoader.java   
public void disablePlugin(Plugin plugin) {
    if (!(plugin instanceof JavaPlugin)) {
        throw new IllegalArgumentException("Plugin is not associated with this PluginLoader");
    }

    if (plugin.isEnabled()) {
        String message = String.format("Disabling %s", plugin.getDescription().getFullName());
        plugin.getLogger().info(message);

        server.getPluginManager().callEvent(new PluginDisableEvent(plugin));

        JavaPlugin jPlugin = (JavaPlugin) plugin;
        ClassLoader cloader = jPlugin.getClassLoader();

        try {
            jPlugin.setEnabled(false);
        } catch (Throwable ex) {
            server.getLogger().log(Level.SEVERE, "Error occurred while disabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex);
        }

        loaders.remove(jPlugin.getDescription().getName());

        if (cloader instanceof PluginClassLoader) {
            PluginClassLoader loader = (PluginClassLoader) cloader;
            Set<String> names = loader.getClasses();

            for (String name : names) {
                removeClass(name);
            }
        }
    }
}
项目:ReUtil    文件:ComponentManager.java   
@AutoEventHandler
private void onPluginDisable(PluginDisableEvent event, @Bind("plugin") Plugin plugin) {
    ComponentManager componentManager = componentsCache.get(plugin);
    if(componentManager == null)
        return;
    for (ComponentHandle<?, ?> handle : componentManager.handles.values()) {
        if(handle.getSaveMoments().contains(SaveMoment.PluginUnload))
            handle.saveAll();
    }
    componentsCache.remove(plugin);
}
项目:remote-entities-nxt    文件:RemoteEntitiesMain.java   
@EventHandler
public void onPluginDisable(PluginDisableEvent event)
{
    EntityManager manager = RemoteEntities.getManagerOfPlugin(event.getPlugin().getName());
    if(manager != null)
    {
        manager.despawnAll(DespawnReason.PLUGIN_DISABLE);
        if(manager instanceof BaseEntityManager)
            ((BaseEntityManager)manager).teardown();
    }
}
项目:DemigodsRPG    文件:WorldGuardUtil.java   
@EventHandler(priority = EventPriority.MONITOR)
void onPluginDisable(PluginDisableEvent event) {
    if (!ENABLED || event.getPlugin().getName().equals("WorldGuard")) return;
    try {
        ENABLED = false;
    } catch (Exception ignored) {
    }
}
项目:EndHQ-Libraries    文件:RemoteEntities.java   
@EventHandler
public void onPluginDisable(PluginDisableEvent event)
{
    EntityManager manager = RemoteEntities.getManagerOfPlugin(event.getPlugin().getName());
    if(manager != null)
    {
        manager.despawnAll(DespawnReason.PLUGIN_DISABLE);
        manager.unregisterEntityLoader();
    }
}
项目:NucleusFramework    文件:JCGEventListener.java   
@EventHandler
private void onPluginDisable(PluginDisableEvent event) {

    // unregister all event handlers associated with the plugin
    EventManager.unregisterPlugin(event.getPlugin());

    if (Nucleus.getPlugin().isEnabled()) {
        Nucleus.getScriptApiRepo().unregisterPlugin(event.getPlugin());
    }
}
项目:MGLib    文件:MGListener.java   
@EventHandler
public void onPluginDisable(PluginDisableEvent event) {
    for (Minigame mg : Minigame.getMinigameInstances()) {
        if (mg.getPlugin().getName().equals(event.getPlugin().getName())) {
            Minigame.unregisterPlugin(event.getPlugin().getName());
        }
    }
}
项目:Bits    文件:PersistentStoreCoordinator.java   
@EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPluginDisableEvent(PluginDisableEvent pluginDisableEvent)
{
    if (!this.executorService.isShutdown())
    {
        this.executorService.shutdown();
    }
}