Java 类org.bukkit.event.world.WorldUnloadEvent 实例源码

项目:NucleusFramework    文件:Region.java   
@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);
        }
    }
}
项目:NPlugins    文件:WorldListener.java   
/**
 * 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();
            }
        }
    }
}
项目:Uranium    文件:CraftServer.java   
@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;
}
项目:MundoSK    文件:BorderManager.java   
@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());
    }
}
项目:SmallWarps    文件:Warp.java   
@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled = true)
public void onWorldUnload(WorldUnloadEvent e) {
    if (e.getWorld() == this.world) {
        world = null;
        location = null;
    }
}
项目:ThermosRebased    文件:CraftServer.java   
@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;
}
项目:Thermos    文件:CraftServer.java   
@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;
}
项目:KCauldron    文件:CraftServer.java   
@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;
}
项目:CauldronGit    文件:CraftServer.java   
@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;
}
项目:CanaryBukkit    文件:CanaryWorldListener.java   
@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 :(
        }
    });
}
项目:Cauldron-Old    文件:CraftServer.java   
@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;
}
项目:DiffUtils    文件:CraftServer_188.java   
@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;
}
项目:Cauldron-Reloaded    文件:CraftServer.java   
@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;
}
项目:RedProtect    文件:RPWorldListener.java   
@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();
    }
}
项目:FFoKC    文件:CraftServer.java   
@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;
}
项目:Craftbukkit    文件:CraftServer.java   
@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;
}
项目:BlockBank    文件:WorldListener.java   
@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();
    }
}
项目:AlmuraForgeBridge    文件:WorldListener.java   
@EventHandler
public void onWorldUnload(WorldUnloadEvent event) {        
    if (BridgePlugin.getInstance().debugMode) {
        System.out.println("[BRIDGE WORLD LISTENER] Unloading: " + event.getWorld().getName());
        Thread.dumpStack();
    }
}
项目:Cauldron    文件:CraftServer.java   
@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;
}
项目:PV-Star    文件:WorldEventListener.java   
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);
            }
        }
    }
}
项目:Masters    文件:worldHandler.java   
@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.");
        }
    }
}
项目:Warzone    文件:WorldListener.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onWorldUnload(final WorldUnloadEvent event) {
    for(Tracker tracker : this.manager.getTrackers()) {
        tracker.clear(event.getWorld());
    }
}
项目:ProjectAres    文件:LivingEntityMapAdapter.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onWorldUnload(WorldUnloadEvent event) {
    for(Entity entity : event.getWorld().getEntities()) {
        map.remove(entity);
    }
}
项目:ProjectAres    文件:LeakListener.java   
@EventHandler(priority = EventPriority.LOWEST)
public void onWorldChange(WorldUnloadEvent event) {
    leakDetector.expectRelease(event.getWorld(), DEADLINE, true);
}
项目:ProjectAres    文件:PlayerFreezer.java   
@EventHandler(priority = EventPriority.MONITOR)
public void onUnload(WorldUnloadEvent event) {
    armorStands.remove(event.getWorld());
}
项目:CapCat    文件:SignListener.java   
@EventHandler(ignoreCancelled = true)
public void onWorldUnload(WorldUnloadEvent event) {
    plugin.signDB.updateAttachedBlocks();
}
项目:LagMonitor    文件:ThreadSafetyListener.java   
@EventHandler
public void onWorldUnload(WorldUnloadEvent worldUnloadEvent) {
    checkSafety(worldUnloadEvent);
}
项目:Phantom    文件:HiveSVC.java   
@EventHandler
public void on(WorldUnloadEvent e)
{
    installWorld(e.getWorld());
}
项目:DiffUtils    文件:CraftServer_1710.java   
@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();
            WorldSaveEvent event = new WorldSaveEvent(handle.getWorld());
            getPluginManager().callEvent(event);
        } catch (ExceptionWorldConflict ex) {
            getLogger().log(Level.SEVERE, null, ex);
        }
    }

    worlds.remove(world.getName().toLowerCase());
    console.worlds.remove(console.worlds.indexOf(handle));

    return true;
}
项目:Spigot-Plus    文件:WorldManager.java   
@EventHandler
public void onWorldUnload(WorldUnloadEvent event){
    WorldManagerHelper.saveWorldConfig(event.getWorld());
}
项目:CraftBukkit    文件:CraftServer.java   
@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();
            WorldSaveEvent event = new WorldSaveEvent(handle.getWorld());
            getPluginManager().callEvent(event);
        } catch (ExceptionWorldConflict ex) {
            getLogger().log(Level.SEVERE, null, ex);
        }
    }

    worlds.remove(world.getName().toLowerCase());
    console.worlds.remove(console.worlds.indexOf(handle));

    return true;
}
项目:LagMonitor    文件:ThreadSafetyListener.java   
@EventHandler
public void onWorldUnload(WorldUnloadEvent worldUnloadEvent) {
    checkSafety(worldUnloadEvent);
}
项目:SurvivalGamesX    文件:WorldListener.java   
public void disable() {
    WorldInitEvent.getHandlerList().unregister(this);
    WorldUnloadEvent.getHandlerList().unregister(this);
    WorldLoadEvent.getHandlerList().unregister(this);
    WorldSaveEvent.getHandlerList().unregister(this);
}
项目:SurvivalGamesX    文件:WorldListener.java   
@EventHandler(priority = EventPriority.NORMAL)
public void onWorldUnload(WorldUnloadEvent ev) {
    plugin.getDebug().normal("#### " + ev.getWorld().getName() + " was unloaded.");
}
项目:dynmap-structures    文件:DynmapStructuresPlugin.java   
@EventHandler
public void onWorldUnload(WorldUnloadEvent event) {
    this.removeWorld(event.getWorld());
}
项目:flyingblocksapi    文件:FlyingBlocksPlugin.java   
@EventHandler
public void onWorldUnload(WorldUnloadEvent ev) {
    removeFlyingBlocks(ev.getWorld());
}
项目:sensibletoolbox    文件:WorldListener.java   
@EventHandler
public void onWorldUnLoad(WorldUnloadEvent event) {
    LocationManager.getManager().worldUnloaded(event.getWorld());
}
项目:ShankShock-Core    文件:ServerListener.java   
@EventHandler(priority = EventPriority.MONITOR)
public void onWorldUnload(WorldUnloadEvent e) {
    plugin.worlds.remove(e.getWorld().getName());
}
项目:EMS    文件:EMSListener.java   
@EventHandler
public void onWorldUnload(WorldUnloadEvent event) {
    World world = event.getWorld();

    manager.unloadWorld(world);
}
项目:anduneCommonBukkitLib    文件:BukkitServer.java   
@EventHandler
public void worldUnloadEvent(WorldUnloadEvent e) {
    clearWorldCache = true;
}