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


Java WorldUnloadEvent類代碼示例

本文整理匯總了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);
        }
    }
}
 
開發者ID:JCThePants,項目名稱:NucleusFramework,代碼行數:17,代碼來源:Region.java

示例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();
            }
        }
    }
}
 
開發者ID:Ribesg,項目名稱:NPlugins,代碼行數:21,代碼來源:WorldListener.java

示例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;
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:40,代碼來源:CraftServer.java

示例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());
	}
}
 
開發者ID:MundoSK,項目名稱:MundoSK,代碼行數:9,代碼來源:BorderManager.java

示例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;
    }
}
 
開發者ID:AcomputerdogMC,項目名稱:SmallWarps,代碼行數:8,代碼來源:Warp.java

示例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 :(
        }
    });
}
 
開發者ID:CanaryBukkitTeam,項目名稱:CanaryBukkit,代碼行數:11,代碼來源:CanaryWorldListener.java

示例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;
}
 
開發者ID:Techcable,項目名稱:DiffUtils,代碼行數:41,代碼來源:CraftServer_188.java

示例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();
    }
}
 
開發者ID:FabioZumbi12,項目名稱:RedProtect,代碼行數:13,代碼來源:RPWorldListener.java

示例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;
}
 
開發者ID:Bogdan-G,項目名稱:FFoKC,代碼行數:40,代碼來源:CraftServer.java

示例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();
	}
}
 
開發者ID:Drewpercraft,項目名稱:BlockBank,代碼行數:10,代碼來源:WorldListener.java

示例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();
    }
}
 
開發者ID:AlmuraDev,項目名稱:AlmuraForgeBridge,代碼行數:8,代碼來源:WorldListener.java

示例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);
            }
        }
    }
}
 
開發者ID:JCThePants,項目名稱:PV-Star,代碼行數:14,代碼來源:WorldEventListener.java

示例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.");
		}
	}
}
 
開發者ID:Jsawrus,項目名稱:Masters,代碼行數:9,代碼來源:worldHandler.java

示例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());
    }
}
 
開發者ID:WarzoneMC,項目名稱:Warzone,代碼行數:7,代碼來源:WorldListener.java

示例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);
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:7,代碼來源:LivingEntityMapAdapter.java


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