diff options
author | Erik Broes <erikbroes@grum.nl> | 2011-01-15 21:55:53 +0100 |
---|---|---|
committer | Erik Broes <erikbroes@grum.nl> | 2011-01-15 21:55:53 +0100 |
commit | 4dc907f2f6b2183e68389689a75b0ce9669fa473 (patch) | |
tree | 9746b19708c0beb45004aeda3ed550f9e51f1d1f /src/main/java/org/bukkit | |
parent | 8c8f53fd44de8f4d471131abf931cf372f820bce (diff) | |
download | craftbukkit-4dc907f2f6b2183e68389689a75b0ce9669fa473.tar craftbukkit-4dc907f2f6b2183e68389689a75b0ce9669fa473.tar.gz craftbukkit-4dc907f2f6b2183e68389689a75b0ce9669fa473.tar.lz craftbukkit-4dc907f2f6b2183e68389689a75b0ce9669fa473.tar.xz craftbukkit-4dc907f2f6b2183e68389689a75b0ce9669fa473.zip |
Implemented clear/remove for inventories
Diffstat (limited to 'src/main/java/org/bukkit')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/CraftInventory.java | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftInventory.java b/src/main/java/org/bukkit/craftbukkit/CraftInventory.java index f8a95ee9..66a77fd8 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftInventory.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftInventory.java @@ -205,4 +205,35 @@ public class CraftInventory implements org.bukkit.Inventory { return getInventory().c(); } + public void remove(int materialId) { + ItemStack[] items = getContents(); + for (int i = 0; i < items.length; i++) { + if (items[i].getTypeId() == materialId) { + clear(i); + } + } + } + + public void remove(Material material) { + remove(material.getId()); + } + + public void remove(ItemStack item) { + ItemStack[] items = getContents(); + for (int i = 0; i < items.length; i++) { + if (items[i].equals(item)) { + clear(i); + } + } + } + + public void clear(int index) { + setItem(index, null); + } + + public void clear() { + for (int i = 0; i < getSize(); i++) { + clear(i); + } + } } |