3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 20:40:08 +01:00

Expose API for clearing a player's inventory with a successful count

return. Adds BUKKIT-2745
Dieser Commit ist enthalten in:
EvilSeph 2012-10-30 02:52:53 -04:00
Ursprung 856fdc2ab6
Commit 6bf705dd08

Datei anzeigen

@ -89,6 +89,33 @@ public class CraftInventoryPlayer extends CraftInventory implements org.bukkit.i
}
}
public int clear(int id, int data) {
int count = 0;
ItemStack[] items = getContents();
ItemStack[] armor = getArmorContents();
int armorSlot = getSize();
for (int i = 0; i < items.length; i++) {
ItemStack item = items[i];
if (item == null) continue;
if (id > -1 && item.getTypeId() != id) continue;
if (data > -1 && item.getData().getData() != data) continue;
count += item.getAmount();
setItem(i, null);
}
for (ItemStack item : armor) {
if (item == null) continue;
if (id > -1 && item.getTypeId() != id) continue;
if (data > -1 && item.getData().getData() != data) continue;
count += item.getAmount();
setItem(armorSlot++, null);
}
return count;
}
@Override
public HumanEntity getHolder() {
return (HumanEntity) inventory.getOwner();