本文整理匯總了Java中org.bukkit.event.world.WorldUnloadEvent類的典型用法代碼示例。如果您正苦於以下問題:Java WorldUnloadEvent類的具體用法?Java WorldUnloadEvent怎麽用?Java WorldUnloadEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
WorldUnloadEvent類屬於org.bukkit.event.world包,在下文中一共展示了WorldUnloadEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onWorldUnload
import org.bukkit.event.world.WorldUnloadEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
private void onWorldUnload(WorldUnloadEvent event) {
String worldName = event.getWorld().getName();
for (Region region : _instances.keySet()) {
if (region.isDefined() && worldName.equals(region.getWorldName())) {
// remove world from locations, helps garbage collector
//noinspection ConstantConditions
region.getP1().setWorld(null);
//noinspection ConstantConditions
region.getP2().setWorld(null);
}
}
}
示例2: onWorldUnload
import org.bukkit.event.world.WorldUnloadEvent; //導入依賴的package包/類
/**
* Creates an EndWorldHandler if the loaded world is an End world
*
* @param event a World Unload Event
*/
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onWorldUnload(final WorldUnloadEvent event) {
if (event.getWorld().getEnvironment() == Environment.THE_END) {
this.plugin.getLogger().info("Handling " + event.getWorld().getName() + " unload");
final EndWorldHandler handler = this.plugin.getHandler(StringUtil.toLowerCamelCase(event.getWorld().getName()));
if (handler != null) {
try {
handler.unload(false);
} catch (final InvalidConfigurationException e) {
this.plugin.getLogger().severe("An error occured, stacktrace follows:");
e.printStackTrace();
}
}
}
}
示例3: unloadWorld
import org.bukkit.event.world.WorldUnloadEvent; //導入依賴的package包/類
@Override
public boolean unloadWorld(World world, boolean save) {
if (world == null) {
return false;
}
net.minecraft.world.WorldServer handle = ((CraftWorld) world).getHandle();
if (!(console.worlds.contains(handle))) {
return false;
}
if (handle.playerEntities.size() > 0) {
return false;
}
WorldUnloadEvent e = new WorldUnloadEvent(handle.getWorld());
pluginManager.callEvent(e);
if (e.isCancelled()) {
return false;
}
if (save) {
try {
handle.saveAllChunks(true, null);
handle.flush();
WorldSaveEvent event = new WorldSaveEvent(handle.getWorld());
getPluginManager().callEvent(event);
} catch (net.minecraft.world.MinecraftException ex) {
getLogger().log(Level.SEVERE, null, ex);
FMLLog.log(org.apache.logging.log4j.Level.ERROR, ex, "Failed to save world " + handle.getWorld().getName() + " while unloading it.");
}
}
MinecraftForge.EVENT_BUS.post(new WorldEvent.Unload(handle)); // Cauldron - fire unload event before removing world
worlds.remove(world.getName().toLowerCase());
DimensionManager.setWorld(handle.provider.dimensionId, null); // Cauldron - remove world from DimensionManager
return true;
}
示例4: onUnloadWorld
import org.bukkit.event.world.WorldUnloadEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public static void onUnloadWorld(WorldUnloadEvent e) {
if (stablesizes.containsKey(e.getWorld())) {
stablesizes.remove(e.getWorld());
stabletimes.remove(e.getWorld());
origsizes.remove(e.getWorld());
}
}
示例5: onWorldUnload
import org.bukkit.event.world.WorldUnloadEvent; //導入依賴的package包/類
@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled = true)
public void onWorldUnload(WorldUnloadEvent e) {
if (e.getWorld() == this.world) {
world = null;
location = null;
}
}
示例6: onWorldUnload
import org.bukkit.event.world.WorldUnloadEvent; //導入依賴的package包/類
@HookHandler(priority = Priority.CRITICAL)
public void onWorldUnload(final UnloadWorldHook hook) {
server.getPluginManager().callEvent(new WorldUnloadEvent(new CanaryWorld(hook.getWorld())) {
@Override
public void setCancelled(boolean cancelled) {
super.setCancelled(cancelled);
//UnloadWorldHook isn't a CancelableHook :(
}
});
}
示例7: unloadWorld
import org.bukkit.event.world.WorldUnloadEvent; //導入依賴的package包/類
@Override
public boolean unloadWorld(World world, boolean save) {
if (world == null) {
return false;
}
WorldServer handle = ((CraftWorld) world).getHandle();
if (!(console.worlds.contains(handle))) {
return false;
}
if (!(handle.dimension > 1)) {
return false;
}
if (handle.players.size() > 0) {
return false;
}
WorldUnloadEvent e = new WorldUnloadEvent(handle.getWorld());
pluginManager.callEvent(e);
if (e.isCancelled()) {
return false;
}
if (save) {
try {
handle.save(true, null);
handle.saveLevel();
} catch (ExceptionWorldConflict ex) {
getLogger().log(Level.SEVERE, null, ex);
}
}
worlds.remove(world.getName().toLowerCase());
console.worlds.remove(console.worlds.indexOf(handle));
return true;
}
示例8: onWorldUnload
import org.bukkit.event.world.WorldUnloadEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL)
public void onWorldUnload(WorldUnloadEvent e) {
World w = e.getWorld();
try {
RedProtect.get().rm.unload(w);
RedProtect.get().logger.warning("World unloaded: " + w.getName());
}
catch (Exception ex) {
RedProtect.get().logger.severe("RedProtect problem on unload world:");
ex.printStackTrace();
}
}
示例9: unloadWorld
import org.bukkit.event.world.WorldUnloadEvent; //導入依賴的package包/類
@Override
public boolean unloadWorld(World world, boolean save) {
if (world == null) {
return false;
}
net.minecraft.world.WorldServer handle = ((CraftWorld) world).getHandle();
if (!(console.worlds.contains(handle))) {
return false;
}
if (handle.playerEntities.size() > 0) {
return false;
}
WorldUnloadEvent e = new WorldUnloadEvent(handle.getWorld());
pluginManager.callEvent(e);
if (e.isCancelled()) {
return false;
}
if (save) {
try {
handle.saveAllChunks(true, null);
handle.flush();
WorldSaveEvent event = new WorldSaveEvent(handle.getWorld());
getPluginManager().callEvent(event);
} catch (net.minecraft.world.MinecraftException ex) {
getLogger().log(Level.SEVERE, null, ex);
FMLLog.log(org.apache.logging.log4j.Level.ERROR, ex, "Failed to save world " + handle.getWorld().getName() + " while unloading it.");
}
}
MinecraftForge.EVENT_BUS.post(new WorldEvent.Unload(handle)); // Cauldron - fire unload event before removing world
worlds.remove(world.getName().toLowerCase(java.util.Locale.ROOT));
DimensionManager.setWorld(handle.provider.dimensionId, null); // Cauldron - remove world from DimensionManager
return true;
}
示例10: onWorldUnload
import org.bukkit.event.world.WorldUnloadEvent; //導入依賴的package包/類
@EventHandler
public void onWorldUnload(WorldUnloadEvent event)
{
World world = event.getWorld();
if (announcementTasks.containsKey(world.getName())) {
plugin.getLogger().info("Cancelling Announcement Task for " + world.getName());
announcementTasks.get(world.getName()).cancel();
}
}
示例11: onWorldUnload
import org.bukkit.event.world.WorldUnloadEvent; //導入依賴的package包/類
@EventHandler
public void onWorldUnload(WorldUnloadEvent event) {
if (BridgePlugin.getInstance().debugMode) {
System.out.println("[BRIDGE WORLD LISTENER] Unloading: " + event.getWorld().getName());
Thread.dumpStack();
}
}
示例12: onWorldUnload
import org.bukkit.event.world.WorldUnloadEvent; //導入依賴的package包/類
private void onWorldUnload(WorldUnloadEvent event) {
List<IArena> arenas = PVStarAPI.getArenaManager().getArenas();
for (IArena arena : arenas) {
if (arena.getRegion().isDefined()) {
World world = arena.getRegion().getWorld();
if (event.getWorld().equals(world)) {
arena.getSettings().setTransientEnabled(false);
}
}
}
}
示例13: unload
import org.bukkit.event.world.WorldUnloadEvent; //導入依賴的package包/類
@EventHandler (priority = EventPriority.NORMAL)
public void unload(final WorldUnloadEvent evt) {
for (Player pl : Bukkit.getServer().getOnlinePlayers()) {
if (pl.hasPermission("masters.debug")) {
pl.sendMessage(ChatColor.RED + "World " + evt.getWorld().getName() + " has been unloaded.");
}
}
}
示例14: onWorldUnload
import org.bukkit.event.world.WorldUnloadEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onWorldUnload(final WorldUnloadEvent event) {
for(Tracker tracker : this.manager.getTrackers()) {
tracker.clear(event.getWorld());
}
}
示例15: onWorldUnload
import org.bukkit.event.world.WorldUnloadEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onWorldUnload(WorldUnloadEvent event) {
for(Entity entity : event.getWorld().getEntities()) {
map.remove(entity);
}
}