summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/bukkit
diff options
context:
space:
mode:
authorLimb <ibelimb@gmail.com>2011-01-24 07:42:59 +0800
committerWarren <evilseph@unaligned.org>2011-02-04 04:04:16 +0800
commite77b080d833accd713ac0dff048994eadc3b8ae3 (patch)
treef07a95090175cf02c882eb65605298b9972ef1c6 /src/main/java/org/bukkit
parentc1c61b73c9cb2b75e4ae22d0aa4c8bdaa6f2931c (diff)
downloadcraftbukkit-e77b080d833accd713ac0dff048994eadc3b8ae3.tar
craftbukkit-e77b080d833accd713ac0dff048994eadc3b8ae3.tar.gz
craftbukkit-e77b080d833accd713ac0dff048994eadc3b8ae3.tar.lz
craftbukkit-e77b080d833accd713ac0dff048994eadc3b8ae3.tar.xz
craftbukkit-e77b080d833accd713ac0dff048994eadc3b8ae3.zip
Implemented Inventory.contains with a minimum amount of item required. As per feature request #187
Diffstat (limited to 'src/main/java/org/bukkit')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
index 3387235d..3079ae2f 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
@@ -83,7 +83,29 @@ public class CraftInventory implements org.bukkit.inventory.Inventory {
}
return false;
}
+
+ public boolean contains(int materialId, int amount) {
+ for (ItemStack item: getContents()) {
+ if (item.getTypeId() == materialId && item.getAmount() >= amount) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean contains(Material material, int amount) {
+ return contains(material.getId(), amount);
+ }
+ public boolean contains(ItemStack item, int amount) {
+ for (ItemStack i: getContents()) {
+ if (item.equals(i) && item.getAmount() >= amount) {
+ return true;
+ }
+ }
+ return false;
+ }
+
public HashMap<Integer, CraftItemStack> all(int materialId) {
HashMap<Integer, CraftItemStack> slots = new HashMap<Integer, CraftItemStack>();