3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-21 05:50:05 +01:00

Implemented clear/remove for inventories

Dieser Commit ist enthalten in:
Erik Broes 2011-01-15 21:55:53 +01:00
Ursprung 8c8f53fd44
Commit 4dc907f2f6

Datei anzeigen

@ -205,4 +205,35 @@ public class CraftInventory implements org.bukkit.Inventory {
return getInventory().c(); 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);
}
}
} }