mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 07:20:24 +01:00
Implemented clear/remove for inventories
By: Erik Broes <erikbroes@grum.nl>
This commit is contained in:
parent
302b68c3ea
commit
7e48b38166
1 changed files with 31 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue