diff --git a/src/main/java/net/minecraft/server/ContainerEnchantTable.java b/src/main/java/net/minecraft/server/ContainerEnchantTable.java index 1a6619b339..d321b1bdf3 100644 --- a/src/main/java/net/minecraft/server/ContainerEnchantTable.java +++ b/src/main/java/net/minecraft/server/ContainerEnchantTable.java @@ -150,22 +150,22 @@ public class ContainerEnchantTable extends Container { if (!this.world.isStatic) { List list = EnchantmentManager.b(this.l, itemstack, this.costs[i]); - // CraftBukkit start - Map enchants = new HashMap(); - for (Object obj : list) { - EnchantmentInstance instance = (EnchantmentInstance) obj; - enchants.put(org.bukkit.enchantments.Enchantment.getById(instance.enchantment.id), instance.level); - } - CraftItemStack item = new CraftItemStack(itemstack); + if (list != null) { + // CraftBukkit start + Map enchants = new HashMap(); + for (Object obj : list) { + EnchantmentInstance instance = (EnchantmentInstance) obj; + enchants.put(org.bukkit.enchantments.Enchantment.getById(instance.enchantment.id), instance.level); + } + CraftItemStack item = new CraftItemStack(itemstack); - EnchantItemEvent event = new EnchantItemEvent((Player) entityhuman.bukkitEntity, this.getBukkitView(), this.world.getWorld().getBlockAt(this.x, this.y, this.z), item, this.costs[i], enchants, i); - this.world.getServer().getPluginManager().callEvent(event); + EnchantItemEvent event = new EnchantItemEvent((Player) entityhuman.bukkitEntity, this.getBukkitView(), this.world.getWorld().getBlockAt(this.x, this.y, this.z), item, this.costs[i], enchants, i); + this.world.getServer().getPluginManager().callEvent(event); - int level = event.getExpLevelCost(); - if (event.isCancelled() || (level > entityhuman.expLevel)) { - return false; - } - if (enchants.isEmpty() == false) { + int level = event.getExpLevelCost(); + if (event.isCancelled() || (level > entityhuman.expLevel) || enchants.isEmpty()) { + return false; + } entityhuman.levelDown(level); for (Map.Entry entry : event.getEnchantsToAdd().entrySet()) { try {