Java Code Examples for org.bukkit.World#getLivingEntities()

The following examples show how to use org.bukkit.World#getLivingEntities() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KillHandler.java    From EliteMobs with GNU General Public License v3.0 6 votes vote down vote up
private static void killEntityType(CommandSender commandSender, String[] args) {

        if (CommandHandler.permCheck(CommandHandler.KILLALL_SPECIFICENTITY, commandSender)) {

            try {
                EntityType entityType = EntityType.fromName(args[1].toUpperCase());
                int counter = 0;
                for (World world : EliteMobs.validWorldList)
                    for (LivingEntity livingEntity : world.getLivingEntities())
                        if (livingEntity.getType().equals(entityType) &&
                                (EntityTracker.isEliteMob(livingEntity) ||
                                        EntityTracker.isSuperMob(livingEntity))) {
                            livingEntity.remove();
                            counter++;
                        }

                commandSender.sendMessage("Killed " + counter + " Elite " + args[1] + ".");

            } catch (Exception e) {
                commandSender.sendMessage("[EliteMobs] Entity type is not valid!");
            }

        }

    }
 
Example 2
Source File: KillHandler.java    From EliteMobs with GNU General Public License v3.0 5 votes vote down vote up
private static void killPassiveMobs(CommandSender commandSender) {

        if (CommandHandler.permCheck(CommandHandler.KILLALL_PASSIVEELITES, commandSender)) {
            int counter = 0;
            for (World world : EliteMobs.validWorldList)
                for (LivingEntity livingEntity : world.getLivingEntities())
                    if (EntityTracker.isSuperMob(livingEntity)) {
                        livingEntity.remove();
                        counter++;
                    }

            commandSender.sendMessage("Killed " + counter + " Elite Mobs.");

        }
    }
 
Example 3
Source File: EntityIdList.java    From iDisguise with Creative Commons Attribution Share Alike 4.0 International 5 votes vote down vote up
public static void init() {
	entityUIDs = new ConcurrentHashMap<Integer, UUID>();
	playerNames = Maps.synchronizedBiMap(HashBiMap.<UUID, String>create());
	entityTypes = new ConcurrentHashMap<UUID, EntityType>();
	for(World world : Bukkit.getWorlds()) {
		for(LivingEntity livingEntity : world.getLivingEntities()) {
			addEntity(livingEntity);
		}
	}
}
 
Example 4
Source File: WorldGuardHandler.java    From uSkyBlock with GNU General Public License v3.0 5 votes vote down vote up
public static List<LivingEntity> getCreaturesInRegion(World world, ProtectedRegion region) {
    List<LivingEntity> livingEntities = world.getLivingEntities();
    List<LivingEntity> creatures = new ArrayList<>();
    for (LivingEntity e : livingEntities) {
        if (region.contains(asVector(e.getLocation()))) {
            creatures.add(e);
        }
    }
    return creatures;
}