From 2f53dbcd0f2391cb3df3aa7a5eeb1ac21c5900ca Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Sun, 16 Jan 2011 14:34:31 +0100 Subject: [PATCH] Fixed NPE while clearing a slot By: Erik Broes --- .../org/bukkit/craftbukkit/inventory/CraftInventory.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) mode change 100644 => 100755 paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java old mode 100644 new mode 100755 index 173e265897..6773ea35e3 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java @@ -43,8 +43,7 @@ public class CraftInventory implements org.bukkit.inventory.Inventory { public void setContents(ItemStack[] items) { if (getInventory().getContents().length != items.length) { - throw new IllegalArgumentException("Invalid inventory size; expected " - + getInventory().getContents().length); + throw new IllegalArgumentException("Invalid inventory size; expected " + getInventory().getContents().length); } net.minecraft.server.ItemStack[] mcItems = getInventory().getContents(); @@ -54,15 +53,13 @@ public class CraftInventory implements org.bukkit.inventory.Inventory { if (item == null) { mcItems[i] = null; } else { - mcItems[i] = new net.minecraft.server.ItemStack( - item.getTypeId(), item.getAmount(), item.getDamage()); + mcItems[i] = new net.minecraft.server.ItemStack( item.getTypeId(), item.getAmount(), item.getDamage()); } } } public void setItem(int index, ItemStack item) { - getInventory().a(index, new net.minecraft.server.ItemStack( - item.getTypeId(), item.getAmount(), item.getDamage())); + getInventory().a(index, (item == null ? null : new net.minecraft.server.ItemStack( item.getTypeId(), item.getAmount(), item.getDamage()))); } public boolean contains(int materialId) {