当前位置: 首页>>代码示例>>Java>>正文


Java Chunk.isLoaded方法代码示例

本文整理汇总了Java中org.bukkit.Chunk.isLoaded方法的典型用法代码示例。如果您正苦于以下问题:Java Chunk.isLoaded方法的具体用法?Java Chunk.isLoaded怎么用?Java Chunk.isLoaded使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.Chunk的用法示例。


在下文中一共展示了Chunk.isLoaded方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import org.bukkit.Chunk; //导入方法依赖的package包/类
/**
 * Clean the cache
 */
@Override
public void run()
{
    long currentTime = System.currentTimeMillis();

    List<Map.Entry<Chunk, Long>> temp = new ArrayList<>();
    temp.addAll(this.lastChunkCleanUp.entrySet());

    for (Map.Entry<Chunk, Long> entry : temp)
    {
        Chunk chunk = entry.getKey();

        if (!chunk.isLoaded() || (currentTime - entry.getValue() <= 60000))
            continue;

        for (Entity entity : chunk.getEntities())
            if (!(entity instanceof Item || entity instanceof HumanEntity || entity instanceof Minecart))
                entity.remove();

        this.lastChunkCleanUp.remove(chunk);
    }
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:26,代码来源:ChunkListener.java

示例2: LeaveWorldCheck

import org.bukkit.Chunk; //导入方法依赖的package包/类
@EventHandler
public void LeaveWorldCheck(PlayerChangedWorldEvent event) {
	if (ConfigOptimize.chunkUnloader == true && event.getFrom().getPlayers().isEmpty()) {
		Chunk[] loadedChunks = event.getFrom().getLoadedChunks();
		int lcl = loadedChunks.length;
		for (int i = 0; i < lcl; i++) {
			Chunk chunk = loadedChunks[i];
			if (chunk.isLoaded() == true & ChunkKeeper.ShouldKeepList.contains(chunk) == false) {
				chunk.unload();
				ChunkUnloaderTimes++;
			}
		}
	}
}
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:15,代码来源:ChunkUnloader.java

示例3: run

import org.bukkit.Chunk; //导入方法依赖的package包/类
@Override
public void run() {
	if (this.secondsUntilRespawn > 0) {
		if (announceRespawn) {
			if (this.currentMessage >= announceMessages.size()) this.currentMessage = 0;
			
			// Show actionbar messages
			String message = announceMessages.get(currentMessage++)
					.replace("%time%", String.valueOf(secondsUntilRespawn))
					.replace("%formatted-time%", this.getFormattedTime(secondsUntilRespawn));
			plugin.getNMSAbstract().broadcastActionBar(message, worldWrapper.getWorld());
		}

		this.secondsUntilRespawn--;
		return;
	}
	
	// Only respawn if a Player is in the World
	World world = this.worldWrapper.getWorld();
	if (world.getPlayers().size() <= 0) return;
	
	// Start respawn process
	PortalCrystal crystalPos = PortalCrystal.values()[currentCrystal++];
	Location crystalLocation = crystalPos.getRelativeToPortal(world);
	World crystalWorld = crystalLocation.getWorld();
	
	Chunk crystalChunk = crystalWorld.getChunkAt(crystalLocation);
	if (!crystalChunk.isLoaded()) 
		crystalChunk.load();
	
	// Remove any existing crystal
	EnderCrystal existingCrystal = crystalPos.get(world);
	if (existingCrystal != null) existingCrystal.remove();
	
	crystalPos.spawn(world);
	crystalWorld.createExplosion(crystalLocation.getX(), crystalLocation.getY(), crystalLocation.getZ(), 0F, false, false);
	crystalWorld.spawnParticle(Particle.EXPLOSION_HUGE, crystalLocation, 0);
	
	// All crystals respawned
	if (currentCrystal >= 4) {
		
		// If dragon already exists, cancel the respawn process
		if (crystalWorld.getEntitiesByClass(EnderDragon.class).size() >= 1) {
			plugin.getLogger().warning("An EnderDragon is already present in world " + crystalWorld.getName() + ". Dragon respawn cancelled");
			this.nmsAbstract.broadcastActionBar(ChatColor.RED + "Dragon respawn abandonned! Dragon already exists! Slay it!", crystalWorld);
			
			// Destroy all crystals
			for (PortalCrystal portalCrystal : PortalCrystal.values()) {
				Location location = portalCrystal.getRelativeToPortal(world);
				
				portalCrystal.get(world).remove();
				
				crystalWorld.getPlayers().forEach(p -> p.playSound(location, Sound.BLOCK_FIRE_EXTINGUISH, 1000, 1));
				crystalWorld.createExplosion(location.getX(), location.getY(), location.getZ(), 0F, false, false);
			}
			
			this.cancel();
			return;
		}
		
		this.dragonBattle.respawnEnderDragon();
		RespawnSafeguardRunnable.newTimeout(plugin, worldWrapper.getWorld(), dragonBattle);
		
		BattleStateChangeEvent bscEventRespawning = new BattleStateChangeEvent(dragonBattle, dragon, BattleState.CRYSTALS_SPAWNING, BattleState.DRAGON_RESPAWNING);
		Bukkit.getPluginManager().callEvent(bscEventRespawning);
		
		this.worldWrapper.stopRespawn();
		this.cancel();
	}
}
 
开发者ID:2008Choco,项目名称:DragonEggDrop,代码行数:71,代码来源:RespawnRunnable.java


注:本文中的org.bukkit.Chunk.isLoaded方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。