diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java index 81bd9885ed..cd6212727f 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java @@ -3,7 +3,6 @@ package org.bukkit.craftbukkit.inventory; import java.util.HashMap; import java.util.Map; import net.minecraft.server.EnchantmentManager; -import net.minecraft.server.NBTBase; import net.minecraft.server.NBTTagCompound; import net.minecraft.server.NBTTagList; import org.bukkit.enchantments.Enchantment; @@ -135,7 +134,7 @@ public class CraftItemStack extends ItemStack { @Override public int getMaxStackSize() { - return item.getItem().getMaxStackSize(); + return (item == null) ? 0 : item.getItem().getMaxStackSize(); } @Override @@ -152,6 +151,7 @@ public class CraftItemStack extends ItemStack { @Override public int getEnchantmentLevel(Enchantment ench) { + if (item == null) return 0; return EnchantmentManager.getEnchantmentLevel(ench.getId(), item); } @@ -168,7 +168,7 @@ public class CraftItemStack extends ItemStack { @Override public Map getEnchantments() { Map result = new HashMap(); - NBTTagList list = item.getEnchantments(); + NBTTagList list = (item == null) ? null : item.getEnchantments(); if (list == null) { return result; @@ -185,6 +185,8 @@ public class CraftItemStack extends ItemStack { } private void rebuildEnchantments(Map enchantments) { + if (item == null) return; + NBTTagCompound tag = item.tag; NBTTagList list = new NBTTagList("ench");