當前位置: 首頁>>代碼示例>>Java>>正文


Java PluginDisableEvent類代碼示例

本文整理匯總了Java中org.bukkit.event.server.PluginDisableEvent的典型用法代碼示例。如果您正苦於以下問題:Java PluginDisableEvent類的具體用法?Java PluginDisableEvent怎麽用?Java PluginDisableEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PluginDisableEvent類屬於org.bukkit.event.server包,在下文中一共展示了PluginDisableEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: loaderDisablePlugin

import org.bukkit.event.server.PluginDisableEvent; //導入依賴的package包/類
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));
       }
}
 
開發者ID:DevotedMC,項目名稱:ExilePearl,代碼行數:22,代碼來源:TestPluginManager.java

示例2: registerBukkitEvents

import org.bukkit.event.server.PluginDisableEvent; //導入依賴的package包/類
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);
}
 
開發者ID:ElDzi,項目名稱:MoreMobs,代碼行數:27,代碼來源:TinyProtocol.java

示例3: registerBukkitEvents

import org.bukkit.event.server.PluginDisableEvent; //導入依賴的package包/類
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);
}
 
開發者ID:Zahusek,項目名稱:-XclsX-TPAv3-XclsX-,代碼行數:26,代碼來源:TinyProtocolAPI.java

示例4: disablePlugin

import org.bukkit.event.server.PluginDisableEvent; //導入依賴的package包/類
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);
    }
}
 
開發者ID:cyberlis,項目名稱:pploader,代碼行數:25,代碼來源:PythonPluginLoader.java

示例5: registerBukkitEvents

import org.bukkit.event.server.PluginDisableEvent; //導入依賴的package包/類
/**
 * 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);
}
 
開發者ID:edasaki,項目名稱:ZentrelaRPG,代碼行數:31,代碼來源:TinyProtocol.java

示例6: onPluginDisable

import org.bukkit.event.server.PluginDisableEvent; //導入依賴的package包/類
@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());
    });
}
 
開發者ID:MinusKube,項目名稱:SmartInvs,代碼行數:13,代碼來源:InventoryManager.java

示例7: onPluginDisable

import org.bukkit.event.server.PluginDisableEvent; //導入依賴的package包/類
@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.
}
 
開發者ID:Kneesnap,項目名稱:Kineticraft,代碼行數:8,代碼來源:MechanicManager.java

示例8: on

import org.bukkit.event.server.PluginDisableEvent; //導入依賴的package包/類
@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();
    }
}
 
開發者ID:RezzedUp,項目名稱:OpGuard,代碼行數:10,代碼來源:PluginDisableHijack.java

示例9: registerShutdownHandler

import org.bukkit.event.server.PluginDisableEvent; //導入依賴的package包/類
@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);
}
 
開發者ID:aikar,項目名稱:TaskChain,代碼行數:12,代碼來源:BukkitTaskChainFactory.java

示例10: pluginDisable

import org.bukkit.event.server.PluginDisableEvent; //導入依賴的package包/類
@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();
        }
    }
}
 
開發者ID:GameBoxx,項目名稱:GameBoxx,代碼行數:13,代碼來源:Menu.java

示例11: disable

import org.bukkit.event.server.PluginDisableEvent; //導入依賴的package包/類
@EventHandler
void disable(PluginDisableEvent e)
{
	if(!e.getPlugin().getClass().equals(TinyProtocolAPI.class)) return;
	for(Player player : Bukkit.getServer().getOnlinePlayers())
		TabAPI.remove(TinyProtocolAPI.class, player);
}
 
開發者ID:Zahusek,項目名稱:TinyProtocolAPI,代碼行數:8,代碼來源:TabListener.java

示例12: vb

import org.bukkit.event.server.PluginDisableEvent; //導入依賴的package包/類
@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());
	}
}
 
開發者ID:Zahusek,項目名稱:TinyProtocolAPI,代碼行數:11,代碼來源:TabMap.java

示例13: disablePlugin

import org.bukkit.event.server.PluginDisableEvent; //導入依賴的package包/類
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);
            }
        }
    }
}
 
開發者ID:CyberdyneCC,項目名稱:Thermos-Bukkit,代碼行數:31,代碼來源:JavaPluginLoader.java

示例14: onPluginDisable

import org.bukkit.event.server.PluginDisableEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPluginDisable(PluginDisableEvent event)
{
	if (event.getPlugin().equals(plugin))
	{
		closeOpenMenus();
		plugin = null;
	}
}
 
開發者ID:MrLittleKitty,項目名稱:AnnihilationPro,代碼行數:10,代碼來源:ItemMenuListener.java

示例15: disablePlugin

import org.bukkit.event.server.PluginDisableEvent; //導入依賴的package包/類
@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));
    }
}
 
開發者ID:caoli5288,項目名稱:economy,代碼行數:16,代碼來源:SubPluginLoader.java


注:本文中的org.bukkit.event.server.PluginDisableEvent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。