PaperMC/CraftBukkit-Patches/0144-Remove-uneeded-validation.patch

48 lines
1.7 KiB
Diff
Raw Normal View History

2015-05-25 14:05:40 +02:00
From 3f34e4ee12532910b03a8285c717349bd5659373 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
2015-05-25 14:05:40 +02:00
index 736aa69..9a8820b 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
2015-04-16 12:19:45 +02:00
@@ -239,7 +239,7 @@ class CraftMetaItem implements ItemMeta, Repairable {
this.lore = new ArrayList<String>(meta.lore);
}
- if (meta.hasEnchants()) {
+ if (meta.enchantments != null) { // Spigot
this.enchantments = new HashMap<Enchantment, Integer>(meta.enchantments);
}
2015-04-16 12:19:45 +02:00
@@ -573,7 +573,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;
}
2015-04-16 12:19:45 +02:00
@@ -660,7 +660,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() {
--
2015-05-09 22:23:26 +02:00
2.1.4