Paper/CraftBukkit-Patches/0174-Skip-invalid-enchants-in-CraftMetaItem.patch
Zach Brown f7bb4ad8a3 Update from upstream SpigotMC
Included Commits:
Update IRC channel to irc.spi.gt SpigotMC/Spigot@a791c555e7
Remove inv close patch for now SpigotMC/Spigot@a3abb3bea9
Limit TNT Detonations per tick SpigotMC/Spigot@8f9c601aed
Use sane default config values SpigotMC/Spigot@1cbbb9b62e

These commits were not included as they were quickly reverted:
Only close if we are actually placing a block SpigotMC/Spigot@ea0b1b2d67
Revert for the above SpigotMC/Spigot@28faa0bd20
Add isUnbreakable and setUnbreakable to ItemMeta. Also fixes a bug wh... SpigotMC/Spigot@32e6d74a5f
Revert for the above SpigotMC/Spigot@4b5a26b11c
2014-08-24 02:40:45 -05:00

30 lines
1.3 KiB
Diff

From 967631ae5ea4e690ffc14ead5f365c4ab60c8c93 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 adaac09..0a6b139 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
@@ -432,7 +432,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;
--
1.9.1