diff options
author | KHobbits <rob@khobbits.co.uk> | 2013-04-30 01:03:37 +0100 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2013-04-30 01:04:40 +0100 |
commit | 31d9b1fab4a3f3773df0f8a1219dcf745ac628f6 (patch) | |
tree | 01d59ffbd1ffea781365537ee216076e9ffe0904 | |
parent | b50ec3406e1c8fcd575f0ce31ba54f21b8080eda (diff) | |
download | Essentials-31d9b1fab4a3f3773df0f8a1219dcf745ac628f6.tar Essentials-31d9b1fab4a3f3773df0f8a1219dcf745ac628f6.tar.gz Essentials-31d9b1fab4a3f3773df0f8a1219dcf745ac628f6.tar.lz Essentials-31d9b1fab4a3f3773df0f8a1219dcf745ac628f6.tar.xz Essentials-31d9b1fab4a3f3773df0f8a1219dcf745ac628f6.zip |
[Fix] Stacked mobs count towards spawnmob-limit count.
-rw-r--r-- | Essentials/src/com/earth2me/essentials/SpawnMob.java | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/Essentials/src/com/earth2me/essentials/SpawnMob.java b/Essentials/src/com/earth2me/essentials/SpawnMob.java index 81be125ba..393ef8693 100644 --- a/Essentials/src/com/earth2me/essentials/SpawnMob.java +++ b/Essentials/src/com/earth2me/essentials/SpawnMob.java @@ -82,10 +82,10 @@ public class SpawnMob { throw new Exception(_("unableToSpawnMob")); } - if (parts.size() > 1 && !user.isAuthorized("essentials.spawnmob.stack")) - { - throw new Exception(_("cannotStackMob")); - } + if (parts.size() > 1 && !user.isAuthorized("essentials.spawnmob.stack")) + { + throw new Exception(_("cannotStackMob")); + } spawnmob(ess, server, user, user, block.getLocation(), parts, data, mobCount); } @@ -106,16 +106,27 @@ public class SpawnMob { final Location sloc = Util.getSafeDestination(loc); - for(int i = 0; i < parts.size(); i++) + for (int i = 0; i < parts.size(); i++) { Mob mob = Mob.fromName(parts.get(i)); checkSpawnable(ess, sender, mob); } - int serverLimit = ess.getSettings().getSpawnMobLimit(); - if (mobCount > serverLimit) + final int serverLimit = ess.getSettings().getSpawnMobLimit(); + int effectiveLimit = serverLimit / parts.size(); + + if (effectiveLimit < 1) + { + effectiveLimit = 1; + while (parts.size() > serverLimit) + { + parts.remove(serverLimit); + } + } + + if (mobCount > effectiveLimit) { - mobCount = serverLimit; + mobCount = effectiveLimit; sender.sendMessage(_("mobSpawnLimit")); } @@ -126,7 +137,7 @@ public class SpawnMob { spawnMob(ess, server, sender, target, sloc, parts, data); } - sender.sendMessage(mobCount + " " + mob.name.toLowerCase(Locale.ENGLISH) + mob.suffix + " " + _("spawned")); + sender.sendMessage(mobCount * parts.size() + " " + mob.name.toLowerCase(Locale.ENGLISH) + mob.suffix + " " + _("spawned")); } catch (MobException e1) { @@ -160,7 +171,7 @@ public class SpawnMob changeMobData(mob.getType(), spawnedMob, data.get(i), target); } } - + int next = (i + 1); if (next < parts.size()) //If it's the last mob in the list, don't set the mount { |