mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-05 18:27:17 +01:00
Implemented Inventory.contains with a minimum amount of item required. As per feature request #187
This commit is contained in:
parent
c1c61b73c9
commit
e77b080d83
1 changed files with 22 additions and 0 deletions
|
@ -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>();
|
||||
|
||||
|
|
Loading…
Reference in a new issue