2015-02-26 10:40:16 +00:00
|
|
|
From 41727637c2e9a82b6b1cf917dc6c1ad93b70a11b Mon Sep 17 00:00:00 2001
|
2014-08-19 18:40:15 +00:00
|
|
|
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
|
2015-02-26 10:40:16 +00:00
|
|
|
index 67b7d57..fbe1c59 100644
|
2014-08-19 18:40:15 +00:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
2015-02-15 01:52:33 +00:00
|
|
|
@@ -460,7 +460,11 @@ class CraftMetaItem implements ItemMeta, Repairable {
|
2014-08-19 18:40:15 +00:00
|
|
|
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;
|
|
|
|
--
|
2014-11-28 01:17:45 +00:00
|
|
|
2.1.0
|
2014-08-19 18:40:15 +00:00
|
|
|
|