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


Java Entity.remove方法代碼示例

本文整理匯總了Java中org.bukkit.entity.Entity.remove方法的典型用法代碼示例。如果您正苦於以下問題:Java Entity.remove方法的具體用法?Java Entity.remove怎麽用?Java Entity.remove使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.entity.Entity的用法示例。


在下文中一共展示了Entity.remove方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onHit

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST)
public void onHit(EntityDamageEvent event)
{
	if(event.isCancelled()) return;
	Entity hitTarget = event.getEntity();
	if(hitTarget != null && hitTarget instanceof ArmorStand && hitTarget.getCustomName() == "Chair")
		// Chair entity is immune to damage.
		event.setCancelled(true);
	else if(hitTarget != null && hitTarget instanceof Player && hitTarget.getVehicle() != null)
	{
		// Let players stand up if receiving damage.
		Entity vehicle = hitTarget.getVehicle();
		if(vehicle != null && vehicle instanceof ArmorStand && vehicle.getCustomName() == "Chair")
			vehicle.remove();
	}
}
 
開發者ID:FattyMieo,項目名稱:SurvivalPlus,代碼行數:17,代碼來源:Chairs.java

示例2: onMobDeath

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
@EventHandler
public void onMobDeath(EntityDeathEvent event) {
	if(event.getEntity() instanceof Entity){
		Entity e = (Entity) event.getEntity();
		if(e.hasMetadata("challenge")){
			event.getDrops().clear();
			String[] meta = e.getMetadata("challenge").get(0).asString().split(", ");
			final String player = meta[1];
			plugin.getChallenges().addKill(Bukkit.getPlayer(player));
			Bukkit.getPlayer(player).setLevel(plugin.getChallenges().getKillsLeft(Bukkit.getPlayer(player)));
			if(e.getType().equals(EntityType.MAGMA_CUBE) || e.getType().equals(EntityType.SLIME)) {
				e.remove();
			}
			if(plugin.getChallenges().getKillsLeft(Bukkit.getPlayer(player)) == 0){
				plugin.getChallenges().finishChallenge(Bukkit.getPlayer(player), false);
			}
		}
	}
}
 
開發者ID:benNek,項目名稱:AsgardAscension,代碼行數:20,代碼來源:ChallengeListener.java

示例3: removeBlock

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
public void removeBlock(BlockBreakEvent e) {
		for (Entity en : e.getBlock().getWorld().getEntities()) {
			if (en.getCustomName() != null && en.getCustomName().equals(getName()) && en.getLocation().add(-0.5, 0, -0.5).equals(e.getBlock().getLocation())) {
				en.remove();
				en.getWorld().getBlockAt(en.getLocation().add(-0.5, 0, -0.5)).setType(Material.AIR);
				
				ItemStack block = new ItemStack(Material.MONSTER_EGG, 1);
				
				ItemMeta bmeta = block.getItemMeta();
				
				bmeta.setDisplayName(name);
				
				block.setItemMeta(bmeta);
				
				if (e.getPlayer() != null && e.getPlayer().getGameMode().equals(GameMode.CREATIVE)) {
					e.getPlayer().getInventory().addItem(block);
				} else {
					e.getBlock().getWorld().dropItemNaturally(en.getLocation().add(-0.5, 0, -0.5), block);
				}
			}
		}
	//}
}
 
開發者ID:GigaGamma,項目名稱:SuperiorCraft,代碼行數:24,代碼來源:CustomBlock.java

示例4: CheckCrowd

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
@EventHandler
public void CheckCrowd(ChunkLoadEvent evt) {
	if (ConfigOptimize.NoCrowdedEntityenable) {
		Chunk chunk = evt.getChunk();
		Entity[] entities = chunk.getEntities();

		for (Entity e : entities) {
			EntityType type = e.getType();
			int count = 0;
			if (ConfigOptimize.NoCrowdedEntityTypeList.contains("*")
					|| ConfigOptimize.NoCrowdedEntityTypeList.contains(type.name())) {
				count++;
				if (count > ConfigOptimize.NoCrowdedEntityPerChunkLimit && e.getType() != EntityType.PLAYER) {
					e.remove();
				}
			}
		}
	}
}
 
開發者ID:GelandiAssociation,項目名稱:EscapeLag,代碼行數:20,代碼來源:NoCrowdEntity.java

示例5: onSpawn

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
@EventHandler
public void onSpawn(CreatureSpawnEvent event) {
	if (ConfigOptimize.NoCrowdedEntityenable) {
		Chunk chunk = event.getEntity().getLocation().getChunk();
		Entity[] entities = chunk.getEntities();

		for (Entity e : entities) {
			EntityType type = e.getType();
			int count = 0;
			if (ConfigOptimize.NoCrowdedEntityTypeList.contains("*")
					|| ConfigOptimize.NoCrowdedEntityTypeList.contains(type.name())) {
				count++;
				if (count > ConfigOptimize.NoCrowdedEntityPerChunkLimit && e.getType() != EntityType.PLAYER) {
					e.remove();
				}
			}
		}
	}
}
 
開發者ID:GelandiAssociation,項目名稱:EscapeLag,代碼行數:20,代碼來源:NoCrowdEntity.java

示例6: onPlace

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlace(BlockPlaceEvent e) {
	if (!cm.isAntiPlaceDoorDupe) {
		return;
	}
	// 判斷手裏的物品是否為門
	if (e.getItemInHand().getType() == Material.WOOD_DOOR || e.getItemInHand().getType() == Material.IRON_DOOR) {
		// 清理所在區塊的甘蔗掉落物
		for (Entity entity : e.getPlayer().getLocation().getChunk().getEntities()) {
			if (entity instanceof Item) {
				Material itemType = ((Item) entity).getItemStack().getType();
				if (itemType == Material.SUGAR_CANE || itemType == Material.CACTUS) {
					entity.remove();
				}
			}
		}
	}
}
 
開發者ID:jiongjionger,項目名稱:NeverLag,代碼行數:19,代碼來源:AntiPlaceDoorDupe.java

示例7: start

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
@Override
public void start() {
    worldName = getPhase().getFeature(MapFeature.class).getWorld().getName();

    if (removeExisting) {
        for (Entity entity : getPhase().getFeature(MapFeature.class).getWorld().getEntities()) {
            if (blacklist.length != 0) {
                if (Arrays.stream(blacklist).anyMatch(m -> m.equals(entity.getType()))) {
                    entity.remove();
                }
            } else if (whitelist.length != 0) {
                if (Arrays.stream(whitelist).noneMatch(m -> m.equals(entity.getType()))) {
                    entity.remove();
                }
            } else {
                entity.remove();
            }
        }
    }
}
 
開發者ID:VoxelGamesLib,項目名稱:VoxelGamesLibv2,代碼行數:21,代碼來源:MobFeature.java

示例8: onCommand

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
	if (command.getName().equalsIgnoreCase("hbike")) {
		Player player = (Player) sender;
		if (args[0].equals("create")) {
			create(player.getLocation()).setPassenger(player);
		}
		else if (args[0].equals("destroy")) {
			for (Entity ent : player.getNearbyEntities(0.2, 0.2, 0.2)) {
				if (ent.getCustomName() != null && ent.getCustomName().equals("HoverBike")) {
					ent.remove();
					return true;
				}
			}
		}
			
		return true;
	}
	
	return false;
}
 
開發者ID:GigaGamma,項目名稱:SuperiorCraft,代碼行數:22,代碼來源:HoverBike.java

示例9: removeLabel

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
public static void removeLabel(Item item) {
    if (itemLabels.containsKey(item.getUniqueId())) {
        Entity e = itemLabels.remove(item.getUniqueId());
        if (e != null)
            e.remove();
        e = null;
    }
}
 
開發者ID:edasaki,項目名稱:ZentrelaRPG,代碼行數:9,代碼來源:DropManager.java

示例10: loadMap

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
public void loadMap() {
	Chat.log(Prefix.LOG_WORLDS + "Generating world: " + worldName + "...");
	
	WorldCreator wc = new WorldCreator(worldName);
	wc.createWorld();
	
	getWorld().setAutoSave(false);
	getWorld().setKeepSpawnInMemory(false);
	getWorld().setFullTime(6000);
	
	for (Entity e : getWorld().getEntities())
		if (e instanceof Player == false)
			e.remove();
}
 
開發者ID:thekeenant,項目名稱:mczone,代碼行數:15,代碼來源:Map.java

示例11: onSpec

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
@EventHandler
public void onSpec(PlayerAliveStatusEvent e) {
    if (e.isAlive()) {
        return;
    }

    Entity entity = e.getPlayer().getVehicle();

    if (entity != null) {
        entity.eject();
        entity.remove();
    }
}
 
開發者ID:ArcadiaPlugins,項目名稱:Arcadia-Spigot,代碼行數:14,代碼來源:HorseRaceGame.java

示例12: killNextCommand

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
private void killNextCommand(Player sender) {
    double distance = 100;
    Entity nearest = null;
    for (final Entity entity : sender.getLocation().getChunk().getEntities()) {
        if (!(entity instanceof Player) && sender.getLocation().distance(entity.getLocation()) < distance) {
            distance = sender.getLocation().distance(entity.getLocation());
            nearest = entity;
        }
    }
    if (nearest != null) {
        nearest.remove();
        sender.sendMessage(Config.getInstance().getPrefix() + "" + ChatColor.GREEN + "You removed entity " + nearest.getType() + '.');
    }
}
 
開發者ID:Shynixn,項目名稱:PetBlocks,代碼行數:15,代碼來源:PetBlockCommandExecutor.java

示例13: endGame

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
public void endGame() {
	gameState = GameState.ENDING;
	if (SkyWarsReloaded.getCfg().bungeeEnabled()&& !shutdown) {
		BungeeUtil.sendSignUpdateRequest(this);
	}
	if (SkyWarsReloaded.getCfg().signJoinMode() && !shutdown) {
		SkyWarsReloaded.getGC().updateSign(gameNumber);
	}
	for (GamePlayer gplayer: getPlayers()) {
		deletePlayer(gplayer, false, false);
	}
	if (SkyWarsReloaded.getCfg().spectatingEnabled()) {
		for (GamePlayer gPlayer: getSpectators()) {
			removeSpectator(gPlayer);
		}
	}
	for (Player player: mapWorld.getPlayers()) {
		if (player != null) {
			player.teleport(SkyWarsReloaded.getCfg().getSpawn(), TeleportCause.PLUGIN);
		}
	}
	
	for (Entity entity: mapWorld.getEntities()) {
		if (entity != null) {
			entity.remove();
		}
	}
	if (!SkyWarsReloaded.getCfg().spectatingEnabled() && !shutdown) {
			SkyWarsReloaded.get().getServer().getScheduler().scheduleSyncDelayedTask(SkyWarsReloaded.get(), new Runnable() {
				@Override
				public void run() {
					deleteGame();
				}
			}, 20 * SkyWarsReloaded.getCfg().getTimeAfterGame());
	} else {
		deleteGame();
	}
}
 
開發者ID:smessie,項目名稱:SkyWarsReloaded,代碼行數:39,代碼來源:Game.java

示例14: chunkUnloadClearBullets

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
/**
 * This eliminates pending bullets on chunk unload
 * 
 * @param event
 */
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void chunkUnloadClearBullets(ChunkUnloadEvent event) {
	if (event.getChunk() == null) return;
	Entity[] entities = event.getChunk().getEntities();
	for (Entity e : entities) {
		if (inFlightBullets.containsKey(e.getUniqueId())) {
			inFlightBullets.remove(e.getUniqueId());
			travelPaths.remove(e.getUniqueId());
			e.remove();
		}
	}
}
 
開發者ID:ProgrammerDan,項目名稱:AddGun,代碼行數:18,代碼來源:Guns.java

示例15: run

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
@Override
public void run() {
    for (final World world : Bukkit.getWorlds()) {
        for (final Entity entity : world.getEntities()) {
            if (BallListener.this.isDeadBall(entity)) {
                entity.remove();
            }
        }
    }
}
 
開發者ID:Shynixn,項目名稱:BlockBall,代碼行數:11,代碼來源:BallListener.java


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