SPIGOT-8038: Skip adding/removing air from inventory via API

This commit is contained in:
md_5 2025-04-13 10:26:41 +10:00
parent 080253d4f4
commit d688748af6
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11

View File

@ -284,6 +284,10 @@ public class CraftInventory implements Inventory {
for (int i = 0; i < items.length; i++) { for (int i = 0; i < items.length; i++) {
ItemStack item = items[i]; ItemStack item = items[i];
Preconditions.checkArgument(item != null, "ItemStack cannot be null"); Preconditions.checkArgument(item != null, "ItemStack cannot be null");
// SPIGOT-8038: Cannot add/remove air. Probably should be an exception, but ignored for compatibility
if (item.getType().isAir()) {
continue;
}
while (true) { while (true) {
// Do we already have a stack of it? // Do we already have a stack of it?
int firstPartial = firstPartial(item); int firstPartial = firstPartial(item);
@ -348,6 +352,10 @@ public class CraftInventory implements Inventory {
for (int i = 0; i < items.length; i++) { for (int i = 0; i < items.length; i++) {
ItemStack item = items[i]; ItemStack item = items[i];
Preconditions.checkArgument(item != null, "ItemStack cannot be null"); Preconditions.checkArgument(item != null, "ItemStack cannot be null");
// SPIGOT-8038: Cannot add/remove air. Probably should be an exception, but ignored for compatibility
if (item.getType().isAir()) {
continue;
}
int toDelete = item.getAmount(); int toDelete = item.getAmount();
while (true) { while (true) {