geforkt von Mirrors/Paper
c7f1eed0bf
3beb7729816 a77ed5758a7 52c130fc6d9
30 Zeilen
1.3 KiB
Diff
30 Zeilen
1.3 KiB
Diff
From 559d797d67136d4fe6773c5cd692295669cea498 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 070b23a..e011d85 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
|
@@ -450,7 +450,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
|
|
|