use of org.bukkit.entity.Slime in project TotalFreedomMod by TotalFreedom.
the class Command_mobpurge method purgeMobs.
public static int purgeMobs() {
int removed = 0;
for (World world : Bukkit.getWorlds()) {
for (Entity ent : world.getLivingEntities()) {
if (ent instanceof Creature || ent instanceof Ghast || ent instanceof Slime || ent instanceof EnderDragon || ent instanceof Ambient) {
ent.remove();
removed++;
}
}
}
return removed;
}
use of org.bukkit.entity.Slime in project TotalFreedomMod by TotalFreedom.
the class MobBlocker method onCreatureSpawn.
@EventHandler(priority = EventPriority.NORMAL)
public void onCreatureSpawn(CreatureSpawnEvent event) {
if (!ConfigEntry.MOB_LIMITER_ENABLED.getBoolean()) {
return;
}
final Entity spawned = event.getEntity();
if (spawned instanceof EnderDragon) {
if (ConfigEntry.MOB_LIMITER_DISABLE_DRAGON.getBoolean()) {
event.setCancelled(true);
return;
}
} else if (spawned instanceof Ghast) {
if (ConfigEntry.MOB_LIMITER_DISABLE_GHAST.getBoolean()) {
event.setCancelled(true);
return;
}
} else if (spawned instanceof Slime) {
if (ConfigEntry.MOB_LIMITER_DISABLE_SLIME.getBoolean()) {
event.setCancelled(true);
return;
}
} else if (spawned instanceof Giant) {
if (ConfigEntry.MOB_LIMITER_DISABLE_GIANT.getBoolean()) {
event.setCancelled(true);
return;
}
} else if (spawned instanceof Bat) {
event.setCancelled(true);
return;
}
int mobLimiterMax = ConfigEntry.MOB_LIMITER_MAX.getInteger();
if (mobLimiterMax <= 0) {
return;
}
int mobcount = 0;
for (Entity entity : event.getLocation().getWorld().getLivingEntities()) {
if (!(entity instanceof HumanEntity)) {
mobcount++;
}
}
if (mobcount > mobLimiterMax) {
event.setCancelled(true);
}
}
Aggregations