13
0
geforkt von Mirrors/Paper

Added missing null check for enchantments. Fixes BUKKIT-897

Dieser Commit ist enthalten in:
Tahg 2012-03-03 05:59:20 -05:00
Ursprung 90fae3b579
Commit 4ac2b08320

Datei anzeigen

@ -150,22 +150,22 @@ public class ContainerEnchantTable extends Container {
if (!this.world.isStatic) { if (!this.world.isStatic) {
List list = EnchantmentManager.b(this.l, itemstack, this.costs[i]); List list = EnchantmentManager.b(this.l, itemstack, this.costs[i]);
// CraftBukkit start if (list != null) {
Map<org.bukkit.enchantments.Enchantment, Integer> enchants = new HashMap<org.bukkit.enchantments.Enchantment, Integer>(); // CraftBukkit start
for (Object obj : list) { Map<org.bukkit.enchantments.Enchantment, Integer> enchants = new HashMap<org.bukkit.enchantments.Enchantment, Integer>();
EnchantmentInstance instance = (EnchantmentInstance) obj; for (Object obj : list) {
enchants.put(org.bukkit.enchantments.Enchantment.getById(instance.enchantment.id), instance.level); EnchantmentInstance instance = (EnchantmentInstance) obj;
} enchants.put(org.bukkit.enchantments.Enchantment.getById(instance.enchantment.id), instance.level);
CraftItemStack item = new CraftItemStack(itemstack); }
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); 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); this.world.getServer().getPluginManager().callEvent(event);
int level = event.getExpLevelCost(); int level = event.getExpLevelCost();
if (event.isCancelled() || (level > entityhuman.expLevel)) { if (event.isCancelled() || (level > entityhuman.expLevel) || enchants.isEmpty()) {
return false; return false;
} }
if (enchants.isEmpty() == false) {
entityhuman.levelDown(level); entityhuman.levelDown(level);
for (Map.Entry<org.bukkit.enchantments.Enchantment, Integer> entry : event.getEnchantsToAdd().entrySet()) { for (Map.Entry<org.bukkit.enchantments.Enchantment, Integer> entry : event.getEnchantsToAdd().entrySet()) {
try { try {