use of org.bukkit.entity.WaterMob in project Essentials by drtshock.
the class Commandremove method removeHandler.
private void removeHandler(final CommandSource sender, final List<String> types, final List<String> customTypes, final World world, int radius) {
int removed = 0;
if (radius > 0) {
radius *= radius;
}
final ArrayList<ToRemove> removeTypes = new ArrayList<>();
final ArrayList<Mob> customRemoveTypes = new ArrayList<>();
for (final String s : types) {
removeTypes.add(ToRemove.valueOf(s));
}
boolean warnUser = false;
for (final String s : customTypes) {
final Mob mobType = Mob.fromName(s);
if (mobType == null) {
warnUser = true;
} else {
customRemoveTypes.add(mobType);
}
}
if (warnUser) {
sender.sendMessage(tl("invalidMob"));
}
for (final Chunk chunk : world.getLoadedChunks()) {
for (final Entity e : chunk.getEntities()) {
if (radius > 0) {
if (sender.getPlayer().getLocation().distanceSquared(e.getLocation()) > radius) {
continue;
}
}
if (e instanceof HumanEntity) {
continue;
}
for (final ToRemove toRemove : removeTypes) {
// We should skip any animals tamed by players unless we are specifially targetting them.
if (e instanceof Tameable && ((Tameable) e).isTamed() && (((Tameable) e).getOwner() instanceof Player || ((Tameable) e).getOwner() instanceof OfflinePlayer) && !removeTypes.contains(ToRemove.TAMED)) {
continue;
}
// We should skip any NAMED animals unless we are specifially targetting them.
if (e instanceof LivingEntity && e.getCustomName() != null && !removeTypes.contains(ToRemove.NAMED)) {
continue;
}
switch(toRemove) {
case TAMED:
if (e instanceof Tameable && ((Tameable) e).isTamed()) {
e.remove();
removed++;
}
break;
case NAMED:
if (e instanceof LivingEntity && e.getCustomName() != null) {
e.remove();
removed++;
}
break;
case DROPS:
if (e instanceof Item) {
e.remove();
removed++;
}
break;
case ARROWS:
if (e instanceof Projectile) {
e.remove();
removed++;
}
break;
case BOATS:
if (e instanceof Boat) {
e.remove();
removed++;
}
break;
case MINECARTS:
if (e instanceof Minecart) {
e.remove();
removed++;
}
break;
case XP:
if (e instanceof ExperienceOrb) {
e.remove();
removed++;
}
break;
case PAINTINGS:
if (e instanceof Painting) {
e.remove();
removed++;
}
break;
case ITEMFRAMES:
if (e instanceof ItemFrame) {
e.remove();
removed++;
}
break;
case ENDERCRYSTALS:
if (e instanceof EnderCrystal) {
e.remove();
removed++;
}
break;
case AMBIENT:
if (e instanceof Flying) {
e.remove();
removed++;
}
break;
case HOSTILE:
case MONSTERS:
if (e instanceof Monster || e instanceof ComplexLivingEntity || e instanceof Flying || e instanceof Slime) {
e.remove();
removed++;
}
break;
case PASSIVE:
case ANIMALS:
if (e instanceof Animals || e instanceof NPC || e instanceof Snowman || e instanceof WaterMob || e instanceof Ambient) {
e.remove();
removed++;
}
break;
case MOBS:
if (e instanceof Animals || e instanceof NPC || e instanceof Snowman || e instanceof WaterMob || e instanceof Monster || e instanceof ComplexLivingEntity || e instanceof Flying || e instanceof Slime || e instanceof Ambient) {
e.remove();
removed++;
}
break;
case ENTITIES:
case ALL:
e.remove();
removed++;
break;
case CUSTOM:
for (final Mob type : customRemoveTypes) {
if (e.getType() == type.getType()) {
e.remove();
removed++;
}
}
break;
}
}
}
}
sender.sendMessage(tl("removed", removed));
}
use of org.bukkit.entity.WaterMob in project Essentials by EssentialsX.
the class Commandremove method removeHandler.
private void removeHandler(final CommandSource sender, final List<String> types, final List<String> customTypes, final World world, int radius) {
int removed = 0;
if (radius > 0) {
radius *= radius;
}
final ArrayList<ToRemove> removeTypes = new ArrayList<>();
final ArrayList<Mob> customRemoveTypes = new ArrayList<>();
for (final String s : types) {
removeTypes.add(ToRemove.valueOf(s));
}
boolean warnUser = false;
for (final String s : customTypes) {
final Mob mobType = Mob.fromName(s);
if (mobType == null) {
warnUser = true;
} else {
customRemoveTypes.add(mobType);
}
}
if (warnUser) {
sender.sendMessage(tl("invalidMob"));
}
for (final Chunk chunk : world.getLoadedChunks()) {
for (final Entity e : chunk.getEntities()) {
if (radius > 0) {
if (sender.getPlayer().getLocation().distanceSquared(e.getLocation()) > radius) {
continue;
}
}
if (e instanceof HumanEntity) {
continue;
}
for (final ToRemove toRemove : removeTypes) {
// We should skip any animals tamed by players unless we are specifially targetting them.
if (e instanceof Tameable && ((Tameable) e).isTamed() && (((Tameable) e).getOwner() instanceof Player || ((Tameable) e).getOwner() instanceof OfflinePlayer) && !removeTypes.contains(ToRemove.TAMED)) {
continue;
}
// We should skip any NAMED animals unless we are specifially targetting them.
if (e instanceof LivingEntity && e.getCustomName() != null && !removeTypes.contains(ToRemove.NAMED)) {
continue;
}
switch(toRemove) {
case TAMED:
if (e instanceof Tameable && ((Tameable) e).isTamed()) {
e.remove();
removed++;
}
break;
case NAMED:
if (e instanceof LivingEntity && e.getCustomName() != null) {
e.remove();
removed++;
}
break;
case DROPS:
if (e instanceof Item) {
e.remove();
removed++;
}
break;
case ARROWS:
if (e instanceof Projectile) {
e.remove();
removed++;
}
break;
case BOATS:
if (e instanceof Boat) {
e.remove();
removed++;
}
break;
case MINECARTS:
if (e instanceof Minecart) {
e.remove();
removed++;
}
break;
case XP:
if (e instanceof ExperienceOrb) {
e.remove();
removed++;
}
break;
case PAINTINGS:
if (e instanceof Painting) {
e.remove();
removed++;
}
break;
case ITEMFRAMES:
if (e instanceof ItemFrame) {
e.remove();
removed++;
}
break;
case ENDERCRYSTALS:
if (e instanceof EnderCrystal) {
e.remove();
removed++;
}
break;
case AMBIENT:
if (e instanceof Flying) {
e.remove();
removed++;
}
break;
case HOSTILE:
case MONSTERS:
if (e instanceof Monster || e instanceof ComplexLivingEntity || e instanceof Flying || e instanceof Slime) {
e.remove();
removed++;
}
break;
case PASSIVE:
case ANIMALS:
if (e instanceof Animals || e instanceof NPC || e instanceof Snowman || e instanceof WaterMob || e instanceof Ambient) {
e.remove();
removed++;
}
break;
case MOBS:
if (e instanceof Animals || e instanceof NPC || e instanceof Snowman || e instanceof WaterMob || e instanceof Monster || e instanceof ComplexLivingEntity || e instanceof Flying || e instanceof Slime || e instanceof Ambient) {
e.remove();
removed++;
}
break;
case ENTITIES:
case ALL:
e.remove();
removed++;
break;
case CUSTOM:
for (final Mob type : customRemoveTypes) {
if (e.getType() == type.getType()) {
e.remove();
removed++;
}
}
break;
}
}
}
}
sender.sendMessage(tl("removed", removed));
}
Aggregations