本文整理匯總了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));
}
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
示例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());
});
}
示例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.
}
示例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();
}
}
示例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);
}
示例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();
}
}
}
示例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);
}
示例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());
}
}
示例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);
}
}
}
}
示例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;
}
}
示例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));
}
}