PaperSpigot-Parent/CraftBukkit-Patches/0150-Remove-uneeded-validation.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

39 lines
1.4 KiB
Diff

From 142f4098cd2b3118351593dfe155cdfa771a0749 Mon Sep 17 00:00:00 2001
From: drXor <mcyoung@mit.edu>
Date: Fri, 15 Aug 2014 18:11:09 -0400
Subject: [PATCH] Remove uneeded validation
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
index 7638832..e134ace 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
@@ -511,7 +511,7 @@ class CraftMetaItem implements ItemMeta, Repairable {
}
static void applyEnchantments(Map<Enchantment, Integer> enchantments, NBTTagCompound tag, ItemMetaKey key) {
- if (enchantments == null || enchantments.size() == 0) {
+ if (enchantments == null /*|| enchantments.size() == 0*/) { // Spigot - remove size check
return;
}
@@ -602,7 +602,14 @@ class CraftMetaItem implements ItemMeta, Repairable {
}
public boolean removeEnchant(Enchantment ench) {
- return hasEnchants() && enchantments.remove(ench) != null;
+ // Spigot start
+ boolean b = hasEnchants() && enchantments.remove( ench ) != null;
+ if ( enchantments != null && enchantments.isEmpty() )
+ {
+ this.enchantments = null;
+ }
+ return b;
+ // Spigot end
}
public boolean hasEnchants() {
--
2.1.0