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


Java EnderCrystal.remove方法代码示例

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


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

示例1: onAttemptRespawn

import org.bukkit.entity.EnderCrystal; //导入方法依赖的package包/类
@EventHandler
public void onAttemptRespawn(PlayerInteractEvent event) {
	Player player = event.getPlayer();
	ItemStack item = event.getItem();
	
	if (item == null || item.getType() != Material.END_CRYSTAL) return;
	if (plugin.getConfig().getBoolean("allow-crystal-respawns")) return;
	
	World world = player.getWorld();
	EndWorldWrapper worldWrapper = plugin.getDEDManager().getWorldWrapper(world);
	if (worldWrapper.isRespawnInProgress() || !world.getEntitiesByClass(EnderDragon.class).isEmpty()) {
		Set<EnderCrystal> crystals = PortalCrystal.getAllSpawnedCrystals(world);
		
		// Check for 3 crystals because PlayerInteractEvent is fired first
		if (crystals.size() < 3) return;
		
		for (EnderCrystal crystal : crystals) {
			crystal.getLocation().getBlock().setType(Material.AIR); // Remove fire
			world.dropItem(crystal.getLocation(), END_CRYSTAL_ITEM);
			crystal.remove();
		}
		
		plugin.getNMSAbstract().sendActionBar(ChatColor.RED + "You cannot manually respawn a dragon!", player);
		player.sendMessage(ChatColor.RED + "You cannot manually respawn a dragon!");
		event.setCancelled(true);
	}
}
 
开发者ID:2008Choco,项目名称:DragonEggDrop,代码行数:28,代码来源:DragonLifeListeners.java

示例2: flagTouch

import org.bukkit.entity.EnderCrystal; //导入方法依赖的package包/类
public void flagTouch(BPPlayer bpPlayer, EnderCrystal flag, Team damagerTeam, boolean chain)
{
	Team flagTeam = getFlagTeam(flag);
	
	if(flagTeam != null)
	{
		Player player = bpPlayer.getPlayer();
		if(Team.areEnemies(damagerTeam, flagTeam))
		{
			takeFlag(bpPlayer, flag, damagerTeam, flagTeam);
			flag.remove();
			player.sendMessage(MessageType.FLAG_STEAL.getTranslation().getValue());
		}
		else
			if (isAtDefaultLocation(flag))
			{
				if (isHoldingFlag(bpPlayer))
					captureFlag(bpPlayer, damagerTeam);
				else
					player.sendMessage(MessageType.FLAG_INFO.getTranslation().getValue());
			}
			else
				returnFlag(bpPlayer, flagTeam);
	}
	else
	{
		flag.remove();
		
		if(chain)
			for(Entity entity : flag.getNearbyEntities(0, 0, 0))
				if(entity instanceof EnderCrystal)
				{
					EnderCrystal cur = (EnderCrystal) entity;
					
					flagTouch(bpPlayer, cur, damagerTeam, false);
				}
	}
}
 
开发者ID:Limeth,项目名称:Breakpoint,代码行数:39,代码来源:FlagManager.java

示例3: run

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