diff options
author | md_5 <git@md-5.net> | 2018-05-04 17:09:46 +1000 |
---|---|---|
committer | md_5 <git@md-5.net> | 2018-05-04 17:09:46 +1000 |
commit | ca057a3457d376b4c38c9765713169505dc17c98 (patch) | |
tree | e303747e4231bfe1b46dc4e6a6b9751f1764bd93 /src/main/java/org/bukkit | |
parent | 1988d7f1045b302b5b58d2018a4d1e27a4dbd8fd (diff) | |
download | craftbukkit-ca057a3457d376b4c38c9765713169505dc17c98.tar craftbukkit-ca057a3457d376b4c38c9765713169505dc17c98.tar.gz craftbukkit-ca057a3457d376b4c38c9765713169505dc17c98.tar.lz craftbukkit-ca057a3457d376b4c38c9765713169505dc17c98.tar.xz craftbukkit-ca057a3457d376b4c38c9765713169505dc17c98.zip |
SPIGOT-3920: Make player inventories consistently return null for empty stacks
Diffstat (limited to 'src/main/java/org/bukkit')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java | 7 | ||||
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java | 4 |
2 files changed, 7 insertions, 4 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java index 4866d1ae..40a73fe8 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java @@ -46,7 +46,10 @@ public class CraftInventory implements Inventory { } 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); } @@ -56,7 +59,7 @@ public class CraftInventory implements Inventory { for (int i = 0; i < size; i++) { net.minecraft.server.ItemStack mcItem = mcItems.get(i); - items[i] = (mcItem.isEmpty()) ? null : CraftItemStack.asCraftMirror(mcItem); + items[i] = asCraftMirror(mcItem); } return items; diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java index 67c54899..0c015d2f 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java @@ -29,7 +29,7 @@ public class CraftInventoryPlayer extends CraftInventory implements org.bukkit.i @Override public ItemStack getItemInMainHand() { - return CraftItemStack.asCraftMirror(getInventory().getItemInHand()); + return asCraftMirror(getInventory().getItemInHand()); } @Override @@ -39,7 +39,7 @@ public class CraftInventoryPlayer extends CraftInventory implements org.bukkit.i @Override public ItemStack getItemInOffHand() { - return CraftItemStack.asCraftMirror(getInventory().extraSlots.get(0)); + return asCraftMirror(getInventory().extraSlots.get(0)); } @Override |