SPIGOT-3920: Make player inventories consistently return null for empty stacks

Dieser Commit ist enthalten in:
md_5 2018-05-04 17:09:46 +10:00
Ursprung 1988d7f104
Commit ca057a3457
2 geänderte Dateien mit 7 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -46,7 +46,10 @@ public class CraftInventory implements Inventory {
} }
public ItemStack getItem(int index) { public ItemStack getItem(int index) {
net.minecraft.server.ItemStack item = getInventory().getItem(index); return asCraftMirror(getInventory().getItem(index));
}
protected static ItemStack asCraftMirror(net.minecraft.server.ItemStack item) {
return item.isEmpty() ? null : CraftItemStack.asCraftMirror(item); return item.isEmpty() ? null : CraftItemStack.asCraftMirror(item);
} }
@ -56,7 +59,7 @@ public class CraftInventory implements Inventory {
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
net.minecraft.server.ItemStack mcItem = mcItems.get(i); net.minecraft.server.ItemStack mcItem = mcItems.get(i);
items[i] = (mcItem.isEmpty()) ? null : CraftItemStack.asCraftMirror(mcItem); items[i] = asCraftMirror(mcItem);
} }
return items; return items;

Datei anzeigen

@ -29,7 +29,7 @@ public class CraftInventoryPlayer extends CraftInventory implements org.bukkit.i
@Override @Override
public ItemStack getItemInMainHand() { public ItemStack getItemInMainHand() {
return CraftItemStack.asCraftMirror(getInventory().getItemInHand()); return asCraftMirror(getInventory().getItemInHand());
} }
@Override @Override
@ -39,7 +39,7 @@ public class CraftInventoryPlayer extends CraftInventory implements org.bukkit.i
@Override @Override
public ItemStack getItemInOffHand() { public ItemStack getItemInOffHand() {
return CraftItemStack.asCraftMirror(getInventory().extraSlots.get(0)); return asCraftMirror(getInventory().extraSlots.get(0));
} }
@Override @Override