summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBlackHole <black-hole@live.com>2017-06-28 18:37:22 +0200
committermd_5 <git@md-5.net>2017-06-29 10:52:33 +1000
commitd603539842fe24dc1b37130e47fafe734a542a69 (patch)
tree5db4fc57a2e2226afceab4b6c80743de8cb90922 /src
parent0481ae963aad545b2f1162d764bcbff18721e2f0 (diff)
downloadcraftbukkit-d603539842fe24dc1b37130e47fafe734a542a69.tar
craftbukkit-d603539842fe24dc1b37130e47fafe734a542a69.tar.gz
craftbukkit-d603539842fe24dc1b37130e47fafe734a542a69.tar.lz
craftbukkit-d603539842fe24dc1b37130e47fafe734a542a69.tar.xz
craftbukkit-d603539842fe24dc1b37130e47fafe734a542a69.zip
SPIGOT-3387: Prevent null enchantments in ItemMeta
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
index ec923673..8d82c4dc 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
@@ -566,10 +566,12 @@ class CraftMetaItem implements ItemMeta, Repairable {
}
public boolean hasEnchant(Enchantment ench) {
+ Validate.notNull(ench, "Enchantment cannot be null");
return hasEnchants() && enchantments.containsKey(ench);
}
public int getEnchantLevel(Enchantment ench) {
+ Validate.notNull(ench, "Enchantment cannot be null");
Integer level = hasEnchants() ? enchantments.get(ench) : null;
if (level == null) {
return 0;
@@ -582,6 +584,7 @@ class CraftMetaItem implements ItemMeta, Repairable {
}
public boolean addEnchant(Enchantment ench, int level, boolean ignoreRestrictions) {
+ Validate.notNull(ench, "Enchantment cannot be null");
if (enchantments == null) {
enchantments = new HashMap<Enchantment, Integer>(4);
}
@@ -594,6 +597,7 @@ class CraftMetaItem implements ItemMeta, Repairable {
}
public boolean removeEnchant(Enchantment ench) {
+ Validate.notNull(ench, "Enchantment cannot be null");
return hasEnchants() && enchantments.remove(ench) != null;
}