summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTahg <tahgtahv@gmail.com>2012-01-09 01:09:36 -0500
committerTahg <tahgtahv@gmail.com>2012-01-09 01:20:54 -0500
commitf6154042c03805a811e84a7c34d9bd7a4b010948 (patch)
tree5cefeb2f370a7bd326522598a1eac3f3dcddb062
parent355c7ba24115709642db9c40f092d2ab12639af5 (diff)
downloadbukkit-f6154042c03805a811e84a7c34d9bd7a4b010948.tar
bukkit-f6154042c03805a811e84a7c34d9bd7a4b010948.tar.gz
bukkit-f6154042c03805a811e84a7c34d9bd7a4b010948.tar.lz
bukkit-f6154042c03805a811e84a7c34d9bd7a4b010948.tar.xz
bukkit-f6154042c03805a811e84a7c34d9bd7a4b010948.zip
Added data argument to vanilla give command
-rw-r--r--src/main/java/org/bukkit/command/defaults/GiveCommand.java12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/main/java/org/bukkit/command/defaults/GiveCommand.java b/src/main/java/org/bukkit/command/defaults/GiveCommand.java
index 62393170..156c2809 100644
--- a/src/main/java/org/bukkit/command/defaults/GiveCommand.java
+++ b/src/main/java/org/bukkit/command/defaults/GiveCommand.java
@@ -12,14 +12,14 @@ public class GiveCommand extends VanillaCommand {
public GiveCommand() {
super("give");
this.description = "Gives the specified player a certain amount of items";
- this.usageMessage = "/give <player> <item> [amount]";
+ this.usageMessage = "/give <player> <item> [amount [data]]";
this.setPermission("bukkit.command.give");
}
@Override
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
if (!testPermission(sender)) return true;
- if ((args.length < 2) || (args.length > 3)) {
+ if ((args.length < 2) || (args.length > 4)) {
sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
return false;
}
@@ -33,6 +33,7 @@ public class GiveCommand extends VanillaCommand {
Command.broadcastCommandMessage(sender, "Giving " + player.getName() + " some " + material.getId() + " (" + material + ")");
int amount = 1;
+ short data = 0;
if (args.length >= 3) {
try {
@@ -41,9 +42,14 @@ public class GiveCommand extends VanillaCommand {
if (amount < 1) amount = 1;
if (amount > 64) amount = 64;
+ if (args.length >= 4) {
+ try {
+ data = Short.parseShort(args[3]);
+ } catch (NumberFormatException ex) {}
+ }
}
- player.getInventory().addItem(new ItemStack(material, amount));
+ player.getInventory().addItem(new ItemStack(material, amount, data));
} else {
sender.sendMessage("There's no item called " + args[1]);
}