Added new player argument: /spawnmob <mob> [amount] [player]

Test: #821
This commit is contained in:
Khyperia 2011-12-07 09:10:24 +08:00 committed by snowleo
parent 9ca0e51dac
commit a82d8d1d44
2 changed files with 12 additions and 6 deletions

View file

@ -76,7 +76,12 @@ public class Commandspawnmob extends EssentialsCommand
{ {
throw new Exception(_("unableToSpawnMob")); throw new Exception(_("unableToSpawnMob"));
} }
final Location loc = block.getLocation(); User otherUser = null;
if (args.length >= 3)
{
otherUser = getPlayer(ess.getServer(), args, 2);
}
final Location loc = (otherUser == null) ? block.getLocation() : otherUser.getLocation();
final Location sloc = Util.getSafeDestination(loc); final Location sloc = Util.getSafeDestination(loc);
try try
{ {
@ -122,7 +127,7 @@ public class Commandspawnmob extends EssentialsCommand
{ {
changeMobData(mobMount.getType(), spawnedMount, mountData, user); changeMobData(mobMount.getType(), spawnedMount, mountData, user);
} }
if (args.length == 2) if (args.length >= 2)
{ {
int mobCount = Integer.parseInt(args[1]); int mobCount = Integer.parseInt(args[1]);
int serverLimit = ess.getSettings().getSpawnMobLimit(); int serverLimit = ess.getSettings().getSpawnMobLimit();
@ -205,7 +210,8 @@ public class Commandspawnmob extends EssentialsCommand
} }
if (type == CreatureType.SHEEP) if (type == CreatureType.SHEEP)
{ {
if (data.toLowerCase(Locale.ENGLISH).contains("baby")) { if (data.toLowerCase(Locale.ENGLISH).contains("baby"))
{
((Sheep)spawned).setAge(-24000); ((Sheep)spawned).setAge(-24000);
} }
final String color = data.toUpperCase(Locale.ENGLISH).replace("BABY", ""); final String color = data.toUpperCase(Locale.ENGLISH).replace("BABY", "");

View file

@ -304,7 +304,7 @@ commands:
aliases: [espawner] aliases: [espawner]
spawnmob: spawnmob:
description: Spawns a mob. description: Spawns a mob.
usage: /<command> <mob>[:data][,<mount>[:data]] [amount] usage: /<command> <mob>[:data][,<mount>[:data]] [amount] [player]
aliases: [espawnmob] aliases: [espawnmob]
sudo: sudo:
description: Make another user perform a command. description: Make another user perform a command.