From f0c0ee1a8dd90de1524032e92c65df5e823a7b1f Mon Sep 17 00:00:00 2001 From: KHobbits Date: Tue, 14 Feb 2012 23:55:29 +0000 Subject: /spawnmob - Only list mobs you have permission to spawn. --- .../earth2me/essentials/commands/Commandspawnmob.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java index f867a1503..948c82871 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java @@ -7,6 +7,7 @@ import com.earth2me.essentials.User; import com.earth2me.essentials.Util; import java.util.Locale; import java.util.Random; +import java.util.Set; import org.bukkit.DyeColor; import org.bukkit.Location; import org.bukkit.Server; @@ -26,7 +27,19 @@ public class Commandspawnmob extends EssentialsCommand { if (args.length < 1) { - throw new NotEnoughArgumentsException(_("mobsAvailable", Util.joinList(Mob.getMobList()))); + Set availableList = Mob.getMobList(); + for (String mob : availableList) + { + if (!user.isAuthorized("essentials.spawnmob." + mob.toLowerCase())) + { + availableList.remove(mob); + } + } + if (availableList.isEmpty()) + { + availableList.add(_("none")); + } + throw new NotEnoughArgumentsException(_("mobsAvailable", Util.joinList(availableList))); } @@ -79,7 +92,7 @@ public class Commandspawnmob extends EssentialsCommand User otherUser = null; if (args.length >= 3) { - otherUser = getPlayer(ess.getServer(), args, 2); + otherUser = getPlayer(ess.getServer(), args, 2); } final Location loc = (otherUser == null) ? block.getLocation() : otherUser.getLocation(); final Location sloc = Util.getSafeDestination(loc); -- cgit v1.2.3