diff options
author | Tahg <tahgtahv@gmail.com> | 2012-03-03 05:59:20 -0500 |
---|---|---|
committer | Tahg <tahgtahv@gmail.com> | 2012-03-03 05:59:40 -0500 |
commit | 4ac2b08320f0298cbb2a66eefc5b3db5bb68e2ef (patch) | |
tree | bd369b0e7506c6a9187516c7f7a61d9aac765653 /src/main/java/net/minecraft/server/ContainerEnchantTable.java | |
parent | 90fae3b579b175164d14bf000d18d49863eb4557 (diff) | |
download | craftbukkit-4ac2b08320f0298cbb2a66eefc5b3db5bb68e2ef.tar craftbukkit-4ac2b08320f0298cbb2a66eefc5b3db5bb68e2ef.tar.gz craftbukkit-4ac2b08320f0298cbb2a66eefc5b3db5bb68e2ef.tar.lz craftbukkit-4ac2b08320f0298cbb2a66eefc5b3db5bb68e2ef.tar.xz craftbukkit-4ac2b08320f0298cbb2a66eefc5b3db5bb68e2ef.zip |
Added missing null check for enchantments. Fixes BUKKIT-897
Diffstat (limited to 'src/main/java/net/minecraft/server/ContainerEnchantTable.java')
-rw-r--r-- | src/main/java/net/minecraft/server/ContainerEnchantTable.java | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/main/java/net/minecraft/server/ContainerEnchantTable.java b/src/main/java/net/minecraft/server/ContainerEnchantTable.java index 1a6619b3..d321b1bd 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<org.bukkit.enchantments.Enchantment, Integer> enchants = new HashMap<org.bukkit.enchantments.Enchantment, Integer>(); - 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<org.bukkit.enchantments.Enchantment, Integer> enchants = new HashMap<org.bukkit.enchantments.Enchantment, Integer>(); + 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<org.bukkit.enchantments.Enchantment, Integer> entry : event.getEnchantsToAdd().entrySet()) { try { |