Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-23 14:50:08 +01:00
Implemented Inventory.contains with a minimum amount of item required. As per feature request #187
Dieser Commit ist enthalten in:
Ursprung
c1c61b73c9
Commit
e77b080d83
@ -84,6 +84,28 @@ public class CraftInventory implements org.bukkit.inventory.Inventory {
|
|||||||
return false;
|
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) {
|
public HashMap<Integer, CraftItemStack> all(int materialId) {
|
||||||
HashMap<Integer, CraftItemStack> slots = new HashMap<Integer, CraftItemStack>();
|
HashMap<Integer, CraftItemStack> slots = new HashMap<Integer, CraftItemStack>();
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren