diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_mp.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_mp.java index f35985b..4ce4616 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_mp.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_mp.java @@ -20,9 +20,9 @@ public class Command_mp extends TFM_Command int removed = 0; for (World world : Bukkit.getWorlds()) { - for (Entity ent : world.getEntities()) + for (Entity ent : world.getLivingEntities()) { - if (ent instanceof Creature || ent instanceof Ghast || ent instanceof Slime) + if (ent instanceof Creature || ent instanceof Ghast || ent instanceof Slime || ent instanceof EnderDragon) { ent.remove(); removed++; diff --git a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_EntityListener.java b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_EntityListener.java index d700406..e3818ce 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_EntityListener.java +++ b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_EntityListener.java @@ -3,7 +3,14 @@ package me.StevenLawson.TotalFreedomMod.Listener; import me.StevenLawson.TotalFreedomMod.TFM_UserInfo; import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; +import org.bukkit.Bukkit; +import org.bukkit.World; +import org.bukkit.entity.Creature; +import org.bukkit.entity.EnderDragon; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Ghast; import org.bukkit.entity.Player; +import org.bukkit.entity.Slime; import org.bukkit.event.entity.*; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; @@ -83,11 +90,31 @@ public class TFM_EntityListener extends EntityListener { if (TotalFreedomMod.mobLimiterEnabled) { + if (event.getEntity() instanceof Ghast || event.getEntity() instanceof Slime || event.getEntity() instanceof EnderDragon) + { + event.setCancelled(true); + return; + } + if (TotalFreedomMod.mobLimiterMax > 0) { - if (TFM_Util.getMobAmount(event.getEntity().getWorld()) > TotalFreedomMod.mobLimiterMax) + int mobcount = 0; + + for (World world : Bukkit.getWorlds()) + { + for (Entity ent : world.getLivingEntities()) + { + if (ent instanceof Creature || ent instanceof Ghast || ent instanceof Slime || ent instanceof EnderDragon) + { + mobcount++; + } + } + } + + if (mobcount > TotalFreedomMod.mobLimiterMax) { event.setCancelled(true); + return; } } } diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java b/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java index 1fde91d..5214ad1 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java @@ -580,18 +580,4 @@ public class TFM_Util } } } - - public static int getMobAmount(World world) - { - List mobs = world.getLivingEntities(); - for (int j = 0; j < mobs.size(); j++) - { - if (!Creature.class.isInstance(mobs.get(j))) - { - mobs.remove(j); - j--; - } - } - return mobs.size(); - } }