From bb83dcc82873d4931bd3ec2120d8ec3f41f25d6e Mon Sep 17 00:00:00 2001 From: KHobbits Date: Sat, 7 Apr 2012 04:39:12 +0100 Subject: [PATCH] Allow vanilla syntax of /give --- .../com/earth2me/essentials/commands/Commandgive.java | 10 ++++++++-- .../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 argList = new ArrayList(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)