use of org.spongepowered.api.world.World 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);
}
use of org.spongepowered.api.world.World in project ClearMob by axle2005.
the class CommandClearChunks method execute.
@Override
public CommandResult execute(CommandSource src, CommandContext arguments) throws CommandException {
if (!Util.playerPermCheck(src, "clearmob.admin")) {
return CommandResult.empty();
} else {
int unloaded = 0;
for (World w : plugin.getWorlds()) {
for (Chunk c : w.getLoadedChunks()) {
if (c.unloadChunk()) {
unloaded++;
}
}
}
src.sendMessage(Text.of(TextColors.AQUA, "[ClearMob] Unloaded: " + unloaded + " chunks"));
return CommandResult.empty();
}
}
use of org.spongepowered.api.world.World in project ClearMob by axle2005.
the class CommandDump method entityDump.
private void entityDump() {
List<String> listdump = new ArrayList<String>();
List<Integer> count = new ArrayList<Integer>();
for (World world : Sponge.getServer().getWorlds()) {
for (Entity entity : world.getEntities()) {
if (!listdump.contains("Entity: " + entity.getType()) && !plugin.getListEntityType().contains(entity.getType())) {
listdump.add("Entity: " + entity.getType());
count.add(1);
} else if (listdump.contains("Entity: " + entity.getType())) {
count.set(listdump.indexOf("Entity: " + entity.getType()), count.get(listdump.indexOf("Entity: " + entity.getType())) + 1);
}
}
}
if (listdump.isEmpty()) {
plugin.getLogger().info("No Entities to Add");
} else {
for (int i = 0; i <= listdump.size() - 1; i++) {
plugin.getLogger().info(listdump.get(i) + ": (" + count.get(i) + ")");
}
}
}
use of org.spongepowered.api.world.World in project ClearMob by axle2005.
the class ClearEntity method run.
public static void run(ClearMob plugin, List<EntityType> list, Collection<World> worlds, CommandSource src) {
int removedentities = 0;
//Collection<Entity> e = new ArrayList<Entity>();
Map<UUID, Entity> entityData = new ConcurrentHashMap<>();
for (World world : worlds) {
for (Entity entity : world.getEntities()) {
entityData.put(entity.getUniqueId(), entity);
plugin.getLogger().info("Test");
//e.add(entity);
}
}
for (Entity en : entityData.values()) {
for (int i = 0; i <= list.size() - 1; i++) {
if ((en.getType().equals(list.get(i)))) {
en.remove();
entityData.remove(en.getUniqueId());
removedentities++;
}
}
}
/*if (!e.isEmpty()) {
for (Entity entity : e) {
for (int i = 0; i <= list.size() - 1; i++) {
if ((entity.getType().equals(list.get(i)))) {
entity.remove();
removedentities++;
}
}
}
}*/
feedback(plugin, src, removedentities);
}
use of org.spongepowered.api.world.World in project ClearMob by axle2005.
the class ClearTileEntity method run.
public static void run(ClearMob plugin, TileEntityType tile, Collection<World> worlds, CommandSource src) {
int removedentities = 0;
Collection<TileEntity> e = new ArrayList<TileEntity>();
for (World world : worlds) {
for (TileEntity entity : world.getTileEntities()) {
e.add(entity);
}
}
if (!e.isEmpty()) {
for (TileEntity entity : e) {
if ((entity.getType().equals(tile))) {
entity.getLocation().removeBlock(Cause.source(Sponge.getPluginManager().fromInstance(plugin).get()).build());
removedentities++;
}
}
}
feedback(plugin, src, removedentities);
}
Aggregations