use of org.spongepowered.api.world.World in project ClearMob by axle2005.
the class CommandDump method tileEntityDump.
private void tileEntityDump() {
List<String> listdump = new ArrayList<String>();
List<Integer> count = new ArrayList<Integer>();
for (World world : Sponge.getServer().getWorlds()) {
for (TileEntity entity : world.getTileEntities()) {
if (!listdump.contains("Tile Entity: " + entity.getType()) && !plugin.getListEntityType().contains(entity.getType())) {
listdump.add("Tile Entity: " + entity.getType());
count.add(1);
} else if (listdump.contains("Tile Entity: " + entity.getType())) {
count.set(listdump.indexOf("Tile Entity: " + entity.getType()), count.get(listdump.indexOf("Tile Entity: " + entity.getType())) + 1);
}
}
}
if (listdump.isEmpty()) {
plugin.getLogger().info("No Tile Entities to Add");
} else {
for (String s : listdump) {
plugin.getLogger().info(s);
}
}
}
use of org.spongepowered.api.world.World in project ClearMob by axle2005.
the class CommandDump method entityAllDump.
private void entityAllDump() {
List<String> listentitydump = new ArrayList<String>();
List<String> listtiledump = new ArrayList<String>();
List<Integer> listentitycount = new ArrayList<Integer>();
List<Integer> listtilecount = new ArrayList<Integer>();
for (World world : Sponge.getServer().getWorlds()) {
for (Entity entity : world.getEntities()) {
if (!listentitydump.contains("Entity: " + entity.getType().getId())) {
listentitydump.add("Entity: " + entity.getType().getId());
listentitycount.add(1);
} else if (listentitydump.contains("Entity: " + entity.getType().getId())) {
listentitycount.set(listentitydump.indexOf("Entity: " + entity.getType().getId()), listentitycount.get(listentitydump.indexOf("Entity: " + entity.getType().getId())) + 1);
}
}
for (TileEntity entity : world.getTileEntities()) {
if (!listtiledump.contains("Tile Entity: " + entity.getType().getId())) {
listtiledump.add("Tile Entity: " + entity.getType().getId());
listtilecount.add(1);
} else if (listtiledump.contains("Tile Entity: " + entity.getType().getId())) {
listtilecount.set(listtiledump.indexOf("Tile Entity: " + entity.getType().getId()), listtilecount.get(listtiledump.indexOf("Tile Entity: " + entity.getType().getId())) + 1);
}
}
}
if (listentitydump.isEmpty()) {
plugin.getLogger().info("No Entities to Add");
} else {
for (int i = 0; i <= listentitydump.size() - 1; i++) {
plugin.getLogger().info(listentitydump.get(i) + ": (" + listentitycount.get(i) + ")");
}
}
if (listtiledump.isEmpty()) {
plugin.getLogger().info("No Tile Entities to Add");
} else {
for (int i = 0; i <= listtiledump.size() - 1; i++) {
plugin.getLogger().info(listtiledump.get(i) + ": (" + listtilecount.get(i) + ")");
}
}
}
use of org.spongepowered.api.world.World in project ClearMob by axle2005.
the class CommandStats method execute.
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
if (!Util.playerPermCheck(src, "clearmob.tps")) {
return CommandResult.empty();
} else {
src.sendMessage(this.HEADER);
double tps = Sponge.getServer().getTicksPerSecond();
src.sendMessage(Text.builder("Current TPS (" + tps + "):").color(TextColors.GOLD).build());
src.sendMessage(constructTickbar(tps));
src.sendMessage(Text.EMPTY);
src.sendMessage(Text.builder("Worlds:").color(TextColors.GOLD).build());
for (World w : Sponge.getServer().getWorlds()) {
src.sendMessage(Text.of("- " + w.getName() + " (" + w.getEntities().size() + " entities, " + w.getTileEntities().size() + " tile, " + +Iterables.size(w.getLoadedChunks()) + " loaded chunks)"));
}
src.sendMessage(this.HEADER);
return CommandResult.success();
}
}
use of org.spongepowered.api.world.World in project ClearMob by axle2005.
the class EntityLimiter method handle.
@Listener(beforeModifications = true)
public void handle(SpawnEntityEvent event) throws Exception {
List<Entity> entity = event.getEntities();
Integer count = 0;
Integer xpcount = 0;
for (World w : plugin.getWorlds()) {
for (Entity e : w.getEntities()) {
if (e instanceof Monster && !(e instanceof Boss)) {
count++;
}
if (e instanceof ExperienceOrb) {
xpcount++;
}
}
}
for (int i = 0; i < entity.size(); i++) {
if (entity.get(i) instanceof Monster && (count > plugin.getMobLimit()) && !(entity.get(i) instanceof Boss)) {
event.setCancelled(true);
}
if ((entity.get(i) instanceof ExperienceOrb && entity.get(i).getNearbyEntities(10).size() > 20)) {
event.setCancelled(true);
}
}
}
use of org.spongepowered.api.world.World in project ClearMob by axle2005.
the class ClearEntity method run.
public static void run(ClearMob plugin, EntityType tile, Collection<World> worlds, CommandSource src) {
int removedentities = 0;
Collection<Entity> e = new ArrayList<Entity>();
for (World world : worlds) {
for (Entity entity : world.getEntities()) {
e.add(entity);
}
}
if (!e.isEmpty()) {
for (Entity entity : e) {
if (!(entity instanceof Item) && !(entity instanceof Player) && !(entity instanceof ExperienceOrb)) {
if ((entity.getType().equals(tile))) {
entity.getLocation().removeBlock(Cause.source(Sponge.getPluginManager().fromInstance(plugin).get()).build());
removedentities++;
}
}
}
}
feedback(plugin, src, removedentities);
}
Aggregations