From 27dffd15331d4831182328514874d0109a932deb Mon Sep 17 00:00:00 2001 From: ementalo Date: Wed, 4 May 2011 16:22:38 +0000 Subject: [PATCH] [trunk] Untested - /sell inventory sells all your inventory minus armour stuff, /sell blocks sells blocks only git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1343 e251c2fe-e539-e718-e476-b85c1f46cddb --- .../essentials/commands/Commandsell.java | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsell.java b/Essentials/src/com/earth2me/essentials/commands/Commandsell.java index 0d06fe4c8..a9e98cddc 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsell.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsell.java @@ -24,19 +24,43 @@ public class Commandsell extends EssentialsCommand throw new NotEnoughArgumentsException(); } ItemStack is; + ItemStack[] isArray; if (args[0].equalsIgnoreCase("hand")) { is = user.getItemInHand(); + + } + if (args[0].equalsIgnoreCase("inventory")) + { + for (ItemStack stack : user.getInventory().getContents()) + { + if(stack.getType() == Material.AIR) continue; + sellItem(user, stack, args); + } + return; + } + if (args[0].equalsIgnoreCase("blocks")) + { + for (ItemStack stack : user.getInventory().getContents()) + { + if (stack.getTypeId() > 255 || stack.getType() == Material.AIR) continue; + sellItem(user, stack, args); + } + return; } else { is = ItemDb.get(args[0]); } + sellItem(user, is, args); + } + + private void sellItem(User user, ItemStack is, String[] args) throws Exception + { if (is == null || is.getType() == Material.AIR) { throw new Exception("You really tried to sell Air? Put an item in your hand."); } - int id = is.getTypeId(); int amount = 0; if (args.length > 1)