summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2013-01-29 20:29:03 +0100
committersnowleo <schneeleo@gmail.com>2013-01-29 20:29:03 +0100
commit3ec9da40cba4c2ae16266df68dcaab5a954de04d (patch)
tree9ba793e1b1c0395875cd4c58f521594fc1722ce8
parentd3087cc1652b26013b034035d46216b14fd3ef2d (diff)
downloadEssentials-3ec9da40cba4c2ae16266df68dcaab5a954de04d.tar
Essentials-3ec9da40cba4c2ae16266df68dcaab5a954de04d.tar.gz
Essentials-3ec9da40cba4c2ae16266df68dcaab5a954de04d.tar.lz
Essentials-3ec9da40cba4c2ae16266df68dcaab5a954de04d.tar.xz
Essentials-3ec9da40cba4c2ae16266df68dcaab5a954de04d.zip
Update /sell command to newer bukkit api
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandsell.java18
1 files changed, 5 insertions, 13 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsell.java b/Essentials/src/com/earth2me/essentials/commands/Commandsell.java
index ec3262958..5bee4766e 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandsell.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandsell.java
@@ -117,19 +117,7 @@ public class Commandsell extends EssentialsCommand
int max = 0;
for (ItemStack s : user.getInventory().getContents())
{
- if (s == null)
- {
- continue;
- }
- if (s.getTypeId() != is.getTypeId())
- {
- continue;
- }
- if (s.getDurability() != is.getDurability())
- {
- continue;
- }
- if (!s.getEnchantments().equals(is.getEnchantments()))
+ if (s == null || !s.isSimilar(is))
{
continue;
}
@@ -166,6 +154,10 @@ public class Commandsell extends EssentialsCommand
//TODO: Prices for Enchantments
final ItemStack ris = is.clone();
ris.setAmount(amount);
+ if (!user.getInventory().containsAtLeast(ris, amount)) {
+ // This should never happen.
+ throw new IllegalStateException("Trying to remove more items than are available.");
+ }
user.getInventory().removeItem(ris);
user.updateInventory();
Trade.log("Command", "Sell", "Item", user.getName(), new Trade(ris, ess), user.getName(), new Trade(worth * amount, ess), user.getLocation(), ess);