本文整理汇总了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));
}
}