diff options
author | Nathan Adams <dinnerbone@dinnerbone.com> | 2011-12-05 01:51:33 +0000 |
---|---|---|
committer | Nathan Adams <dinnerbone@dinnerbone.com> | 2011-12-05 01:51:33 +0000 |
commit | 8363eadcabe1ac9277842e75d56a7409ef6e3ced (patch) | |
tree | 83c3eb3a9d6c01e6f88fa76c5bf82736ededea54 /src | |
parent | dbd3ff71fc7f07abb36843616bf7d1e832e32655 (diff) | |
download | craftbukkit-8363eadcabe1ac9277842e75d56a7409ef6e3ced.tar craftbukkit-8363eadcabe1ac9277842e75d56a7409ef6e3ced.tar.gz craftbukkit-8363eadcabe1ac9277842e75d56a7409ef6e3ced.tar.lz craftbukkit-8363eadcabe1ac9277842e75d56a7409ef6e3ced.tar.xz craftbukkit-8363eadcabe1ac9277842e75d56a7409ef6e3ced.zip |
CraftInventory.remove shouldn't care about amount (BUKKIT-138)
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java index 6f1bcaad..801d5f23 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java @@ -160,12 +160,24 @@ public class CraftInventory implements org.bukkit.inventory.Inventory { } public int first(ItemStack item) { + return first(item, true); + } + + public int first(ItemStack item, boolean withAmount) { if (item == null) { return -1; } ItemStack[] inventory = getContents(); for (int i = 0; i < inventory.length; i++) { - if (item.equals(inventory[i])) { + boolean equals = false; + + if (withAmount) { + equals = item.equals(inventory[i]); + } else { + equals = item.getTypeId() == inventory[i].getTypeId() && item.getDurability() == inventory[i].getDurability() && item.getEnchantments().equals(inventory[i].getEnchantments()); + } + + if (equals) { return i; } } @@ -282,7 +294,7 @@ public class CraftInventory implements org.bukkit.inventory.Inventory { int toDelete = item.getAmount(); while (true) { - int first = first(item); + int first = first(item, false); // Drat! we don't have this type in the inventory if (first == -1) { |