Search in sources :

Example 1 with Animal

use of org.spongepowered.api.entity.living.animal.Animal in project ClearMob by axle2005.

the class clearMain method run.

public void run(Boolean[] configoptions, List<EntityType> listEntityType, CommandSource src) {
    int removedEntities = 0;
    Map<UUID, Entity> entityData = new ConcurrentHashMap<>();
    for (World world : Sponge.getServer().getWorlds()) {
        for (Entity entity : world.getEntities()) {
            entityData.put(entity.getUniqueId(), entity);
        }
        for (Entity entity : entityData.values()) {
            if (!entity.isRemoved()) {
                if (entity instanceof Player) {
                } else if (entity.get(DisplayNameData.class).isPresent()) {
                // Checks if entity has nametag and ignores it.
                } else if (configoptions[1] == true && entity instanceof Monster) {
                    // KillAllMonsters
                    removedEntities++;
                    entity.remove();
                } else if (configoptions[2] == true && entity instanceof Item) {
                    // KillDrops
                    if (ClearItems.run(entity, plugin.getListItemType(), plugin.getitemWB())) {
                        removedEntities++;
                    }
                } else if (configoptions[3] == true && entity instanceof Animal) {
                    // KillAnimalGroups
                    removedEntities = removedEntities + animals.run(entity);
                } else {
                    if (wl.clear(entity, plugin.getListEntityType()) == true) {
                        removedEntities++;
                    }
                }
            }
        }
    }
    ClearTileEntity.run(plugin, plugin.getListTileEntityType(), plugin.getWorlds(), src);
    feedback(src, removedEntities);
}
Also used : Entity(org.spongepowered.api.entity.Entity) Item(org.spongepowered.api.entity.Item) Player(org.spongepowered.api.entity.living.player.Player) Animal(org.spongepowered.api.entity.living.animal.Animal) Monster(org.spongepowered.api.entity.living.monster.Monster) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) UUID(java.util.UUID) World(org.spongepowered.api.world.World)

Aggregations

UUID (java.util.UUID)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Entity (org.spongepowered.api.entity.Entity)1 Item (org.spongepowered.api.entity.Item)1 Animal (org.spongepowered.api.entity.living.animal.Animal)1 Monster (org.spongepowered.api.entity.living.monster.Monster)1 Player (org.spongepowered.api.entity.living.player.Player)1 World (org.spongepowered.api.world.World)1