Paper/CraftBukkit-Patches/0153-Skip-invalid-enchants-in-CraftMetaItem.patch
Zach Brown 28414e7e28 Update from upstream SpigotMC
6669d6ecd2b
b2740df50bb
bf71dc61149
fba27a2ea80
92ee7e7f8ec
b28f0d3de23
4beb4ac3918
0ddb6f3dde8
afe301fe892
b8f6402bbbe
2014-12-07 13:26:30 -06:00

30 lines
1.3 KiB
Diff

From 36429dd025bd601b1b681fb79409e8795316c3c8 Mon Sep 17 00:00:00 2001
From: Thinkofdeath <thinkofdeath@spigotmc.org>
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 e134ace..e8c1a99 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
@@ -434,7 +434,11 @@ 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;
--
2.1.0