summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIaccidentally <coryhuckaby@gmail.com>2013-01-28 21:13:41 -0800
committerIaccidentally <coryhuckaby@gmail.com>2013-01-28 21:13:41 -0800
commit57de3f3ed2d6a42372156343021f876d8245d3e1 (patch)
tree447a6f80f2b149c950bd0b9f33e0fd8207e3678b
parent76d1ea5cab0f0d994c344ec60dcd0b1b2a3631a7 (diff)
parent74b63a6f2dc6834fc7d9b8d96e94a64b747f981b (diff)
downloadEssentials-57de3f3ed2d6a42372156343021f876d8245d3e1.tar
Essentials-57de3f3ed2d6a42372156343021f876d8245d3e1.tar.gz
Essentials-57de3f3ed2d6a42372156343021f876d8245d3e1.tar.lz
Essentials-57de3f3ed2d6a42372156343021f876d8245d3e1.tar.xz
Essentials-57de3f3ed2d6a42372156343021f876d8245d3e1.zip
Merge pull request #286 from GunfighterJ/2.9
Ignore itemmeta on selling
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandsell.java22
1 files changed, 17 insertions, 5 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsell.java b/Essentials/src/com/earth2me/essentials/commands/Commandsell.java
index ec3262958..a70b1e3cc 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandsell.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandsell.java
@@ -43,7 +43,7 @@ public class Commandsell extends EssentialsCommand
}
try
{
- totalWorth += sellItem(user, stack, args, true);
+ totalWorth += sellItem(user, stack, args, true);
}
catch (Exception e)
{
@@ -164,11 +164,23 @@ public class Commandsell extends EssentialsCommand
}
//TODO: Prices for Enchantments
- final ItemStack ris = is.clone();
- ris.setAmount(amount);
- user.getInventory().removeItem(ris);
+ ItemStack[] pinv = user.getInventory().getContents();
+ int itemIndex = -1;
+ for (int i = 0; i < pinv.length; i++)
+ {
+ if (pinv[i] != null)
+ {
+ if (pinv[i].getType() == is.getType() && pinv[i].getDurability() == is.getDurability())
+ {
+ itemIndex = i;
+ break;
+ }
+ }
+ }
+ pinv[itemIndex].setAmount(pinv[itemIndex].getAmount() - amount);
+ user.getInventory().setContents(pinv);
user.updateInventory();
- Trade.log("Command", "Sell", "Item", user.getName(), new Trade(ris, ess), user.getName(), new Trade(worth * amount, ess), user.getLocation(), ess);
+ Trade.log("Command", "Sell", "Item", user.getName(), new Trade(pinv[itemIndex], ess), user.getName(), new Trade(worth * amount, ess), user.getLocation(), ess);
user.giveMoney(worth * amount);
user.sendMessage(_("itemSold", Util.displayCurrency(worth * amount, ess), amount, is.getType().toString().toLowerCase(Locale.ENGLISH), Util.displayCurrency(worth, ess)));
logger.log(Level.INFO, _("itemSoldConsole", user.getDisplayName(), is.getType().toString().toLowerCase(Locale.ENGLISH), Util.displayCurrency(worth * amount, ess), amount, Util.displayCurrency(worth, ess)));