diff options
author | KHobbits <rob@khobbits.co.uk> | 2012-04-07 04:39:12 +0100 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2012-04-07 04:39:12 +0100 |
commit | bb83dcc82873d4931bd3ec2120d8ec3f41f25d6e (patch) | |
tree | 81159a394c8997000a8edf53c7f56299238585e7 | |
parent | 0eefb7f5a160dce1285ccf23899700a57fffa2ff (diff) | |
download | Essentials-bb83dcc82873d4931bd3ec2120d8ec3f41f25d6e.tar Essentials-bb83dcc82873d4931bd3ec2120d8ec3f41f25d6e.tar.gz Essentials-bb83dcc82873d4931bd3ec2120d8ec3f41f25d6e.tar.lz Essentials-bb83dcc82873d4931bd3ec2120d8ec3f41f25d6e.tar.xz Essentials-bb83dcc82873d4931bd3ec2120d8ec3f41f25d6e.zip |
Allow vanilla syntax of /give
-rw-r--r-- | Essentials/src/com/earth2me/essentials/commands/Commandgive.java | 10 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/commands/Commandtime.java | 9 |
2 files changed, 13 insertions, 6 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgive.java b/Essentials/src/com/earth2me/essentials/commands/Commandgive.java index 701fa6577..106efa6e9 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandgive.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandgive.java @@ -3,6 +3,7 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.craftbukkit.InventoryWorkaround; import com.earth2me.essentials.User; +import com.earth2me.essentials.Util; import java.util.Locale; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -44,7 +45,12 @@ public class Commandgive extends EssentialsCommand final User giveTo = getPlayer(server, args, 0); - if (args.length > 2 && Integer.parseInt(args[2]) > 0) + if (args.length > 3 && Util.isInt(args[2]) && Util.isInt(args[3])) + { + stack.setDurability(Short.parseShort(args[2])); + stack.setAmount(Integer.parseInt(args[3])); + } + else if (args.length > 2 && Integer.parseInt(args[2]) > 0) { stack.setAmount(Integer.parseInt(args[2])); } @@ -59,7 +65,7 @@ public class Commandgive extends EssentialsCommand if (args.length > 3) { - for (int i = 3; i < args.length; i++) + for (int i = Util.isInt(args[3]) ? 4 : 3; i < args.length; i++) { final String[] split = args[i].split("[:+',;.]", 2); if (split.length < 1) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtime.java b/Essentials/src/com/earth2me/essentials/commands/Commandtime.java index fa1243d45..8e5b7c017 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtime.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtime.java @@ -21,11 +21,12 @@ public class Commandtime extends EssentialsCommand public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { final List<String> argList = new ArrayList<String>(Arrays.asList(args)); - if ((argList.remove("set") || argList.remove("add")) && Util.isInt(argList.get(0))) { - ess.getLogger().info("debug edited 0" + argList.get(0).toString()); + if ((argList.remove("set") || argList.remove("add")) && Util.isInt(argList.get(0))) + { + ess.getLogger().info("debug edited 0" + argList.get(0).toString()); } - final String[] validArgs = argList.toArray(new String[0]); - + final String[] validArgs = argList.toArray(new String[0]); + // Which World(s) are we interested in? String worldSelector = null; if (validArgs.length == 2) |