mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-08-05 12:02:53 +00:00
[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
This commit is contained in:
parent
50780f7399
commit
27dffd1533
1 changed files with 25 additions and 1 deletions
|
@ -24,19 +24,43 @@ public class Commandsell extends EssentialsCommand
|
||||||
throw new NotEnoughArgumentsException();
|
throw new NotEnoughArgumentsException();
|
||||||
}
|
}
|
||||||
ItemStack is;
|
ItemStack is;
|
||||||
|
ItemStack[] isArray;
|
||||||
if (args[0].equalsIgnoreCase("hand"))
|
if (args[0].equalsIgnoreCase("hand"))
|
||||||
{
|
{
|
||||||
is = user.getItemInHand();
|
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
|
else
|
||||||
{
|
{
|
||||||
is = ItemDb.get(args[0]);
|
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)
|
if (is == null || is.getType() == Material.AIR)
|
||||||
{
|
{
|
||||||
throw new Exception("You really tried to sell Air? Put an item in your hand.");
|
throw new Exception("You really tried to sell Air? Put an item in your hand.");
|
||||||
}
|
}
|
||||||
|
|
||||||
int id = is.getTypeId();
|
int id = is.getTypeId();
|
||||||
int amount = 0;
|
int amount = 0;
|
||||||
if (args.length > 1)
|
if (args.length > 1)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue