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


Java Chunk.load方法代码示例

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


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

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