summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorementalo <ementalo@e251c2fe-e539-e718-e476-b85c1f46cddb>2011-05-04 16:22:38 +0000
committerementalo <ementalo@e251c2fe-e539-e718-e476-b85c1f46cddb>2011-05-04 16:22:38 +0000
commit27dffd15331d4831182328514874d0109a932deb (patch)
treebc63e8db0e8afb5f89a9ce4ac2251c2f10a2a41b
parent50780f73997d6ed304255dca440dbc2e7f61a64f (diff)
downloadEssentials-27dffd15331d4831182328514874d0109a932deb.tar
Essentials-27dffd15331d4831182328514874d0109a932deb.tar.gz
Essentials-27dffd15331d4831182328514874d0109a932deb.tar.lz
Essentials-27dffd15331d4831182328514874d0109a932deb.tar.xz
Essentials-27dffd15331d4831182328514874d0109a932deb.zip
[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
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandsell.java26
1 files changed, 25 insertions, 1 deletions
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)