org.bukkit.event.world.ChunkUnloadEvent#getChunk ( )源码实例Demo

下面列出了org.bukkit.event.world.ChunkUnloadEvent#getChunk ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: EntityAPI   文件: SimpleChunkManager.java
@EventHandler
public void onUnload(ChunkUnloadEvent event) {
    Chunk unloadedChunk = event.getChunk();
    for (Entity entity : unloadedChunk.getEntities()) {
        if (entity instanceof LivingEntity) {
            Object handle = BukkitUnwrapper.getInstance().unwrap(entity);
            if (handle instanceof ControllableEntityHandle) {
                ControllableEntity controllableEntity = ((ControllableEntityHandle) handle).getControllableEntity();
                if (controllableEntity != null && controllableEntity.isSpawned()) {
                    this.SPAWN_QUEUE.add(new EntityChunkData(controllableEntity, entity.getLocation()));
                    controllableEntity.despawn(DespawnReason.CHUNK_UNLOAD);
                }
            }
        }
    }
}
 
源代码2 项目: Holograms   文件: HologramListener.java
@EventHandler
public void onChunkUnload(ChunkUnloadEvent event) {
    Chunk chunk = event.getChunk();
    for (Entity entity : chunk.getEntities()) {
        HologramEntity hologramEntity = plugin.getEntityController().getHologramEntity(entity);
        if (hologramEntity != null) {
            hologramEntity.remove();
        }
    }
    Collection<Hologram> holograms = plugin.getHologramManager().getActiveHolograms().values();
    for (Hologram holo : holograms) {
        Location loc = holo.getLocation();
        int chunkX = (int) Math.floor(loc.getBlockX() / 16.0D);
        int chunkZ = (int) Math.floor(loc.getBlockZ() / 16.0D);
        if (chunkX == chunk.getX() && chunkZ == chunk.getZ()) {
            holo.despawn();
        }
    }
}
 
源代码3 项目: iDisguise   文件: EventListener.java
@EventHandler(priority = EventPriority.MONITOR)
public void onChunkUnload(ChunkUnloadEvent event) {
	final Chunk chunk = event.getChunk();
	final List<Integer> entityIds = new ArrayList<Integer>();
	for(Entity entity : chunk.getEntities()) {
		if(entity instanceof LivingEntity) {
			entityIds.add(entity.getEntityId());
		}
	}
	Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
		
		public void run() {
			if(!chunk.isLoaded()) {
				for(int entityId : entityIds) {
					EntityIdList.removeEntity(entityId);
				}
			}
		}
		
	}, 40L); // TODO: increase delay?
}
 
源代码4 项目: BedWars   文件: WorldListener.java
@EventHandler
public void onChunkUnload(ChunkUnloadEvent unload) {
    if (unload instanceof Cancellable) {
        Chunk chunk = unload.getChunk();

        for (String name : Main.getGameNames()) {
            Game game = Main.getGame(name);
            if (game.getStatus() != GameStatus.DISABLED && game.getStatus() != GameStatus.WAITING
                    && GameCreator.isChunkInArea(chunk, game.getPos1(), game.getPos2())) {
                ((Cancellable) unload).setCancelled(false);
                return;
            }
        }
    }
}
 
源代码5 项目: BedWars   文件: WorldListener.java
@EventHandler
public void onChunkUnload(ChunkUnloadEvent unload) {
    if (unload instanceof Cancellable) {
        Chunk chunk = unload.getChunk();

        for (String name : Main.getGameNames()) {
            Game game = Main.getGame(name);
            if (game.getStatus() != GameStatus.DISABLED && game.getStatus() != GameStatus.WAITING
                    && GameCreator.isChunkInArea(chunk, game.getPos1(), game.getPos2())) {
                ((Cancellable) unload).setCancelled(false);
                return;
            }
        }
    }
}
 
源代码6 项目: Civs   文件: ConveyorEffect.java
@EventHandler
public void onChunkUnload(ChunkUnloadEvent event) {
    Chunk chunk = event.getChunk();
    for (Region r : new HashMap<>(carts).keySet()) {
        StorageMinecart sm = carts.get(r);
        if (Util.isWithinChunk(chunk, sm.getLocation())) {
            carts.remove(r);
            orphanCarts.put(r, sm);
        }
    }
}
 
@EventHandler(ignoreCancelled = true)
public void onChunkUnloadEvent(ChunkUnloadEvent event)
{
	World world = event.getWorld();
	Chunk chunk = event.getChunk();
	
	if (!this.plugin.getWorldGuardCommunicator().doUnloadChunkFlagCheck(world, chunk))
	{
		event.setCancelled(true);
	}
}
 
源代码8 项目: FastAsyncWorldedit   文件: BukkitQueue_0.java
@EventHandler
public static void onChunkUnload(ChunkUnloadEvent event) {
    Chunk chunk = event.getChunk();
    long pair = MathMan.pairInt(chunk.getX(), chunk.getZ());
    Long lastLoad = keepLoaded.get(pair);
    if (lastLoad != null) {
        if (Fawe.get().getTimer().getTickStart() - lastLoad < 10000) {
            event.setCancelled(true);
        } else {
            keepLoaded.remove(pair);
        }
    }
}