From 5bbc6ad511097a6fd17b57ca583b36ad25fc7865 Mon Sep 17 00:00:00 2001 From: Zach Brown <1254957+zachbr@users.noreply.github.com> Date: Tue, 19 Aug 2014 13:40:15 -0500 Subject: [PATCH] Update from upstream SpigotMC Skip invalid enchants in CraftMetaItem SpigotMC/Spigot@542e0798daa57976f0b07dcd0eb03e8c46cec197 --- ...ip-invalid-enchants-in-CraftMetaItem.patch | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 CraftBukkit-Patches/0175-Skip-invalid-enchants-in-CraftMetaItem.patch diff --git a/CraftBukkit-Patches/0175-Skip-invalid-enchants-in-CraftMetaItem.patch b/CraftBukkit-Patches/0175-Skip-invalid-enchants-in-CraftMetaItem.patch new file mode 100644 index 0000000000..24921b047b --- /dev/null +++ b/CraftBukkit-Patches/0175-Skip-invalid-enchants-in-CraftMetaItem.patch @@ -0,0 +1,27 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Thinkofdeath +Date: Tue, 19 Aug 2014 11:04:21 +0100 +Subject: [PATCH] Skip invalid enchants in CraftMetaItem + +Its a rare case but when loading a world from a modded server which added enchantments +CraftMetaItem would add a null enchantment into the enchantment map which causes +NullPointers later + +diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Repairable { + int id = 0xffff & ((NBTTagCompound) ench.get(i)).getShort(ENCHANTMENTS_ID.NBT); + int level = 0xffff & ((NBTTagCompound) ench.get(i)).getShort(ENCHANTMENTS_LVL.NBT); + +- enchantments.put(Enchantment.getById(id), level); ++ // Spigot start - skip invalid enchantments ++ Enchantment e = Enchantment.getById(id); ++ if (e == null) continue; ++ // Spigot end ++ enchantments.put(e, level); + } + + return enchantments; +-- \ No newline at end of file