diff --git a/plugin/src/main/java/net/aufdemrand/denizen/objects/properties/item/ItemEnchantments.java b/plugin/src/main/java/net/aufdemrand/denizen/objects/properties/item/ItemEnchantments.java index 9347460c51..42d7127c84 100644 --- a/plugin/src/main/java/net/aufdemrand/denizen/objects/properties/item/ItemEnchantments.java +++ b/plugin/src/main/java/net/aufdemrand/denizen/objects/properties/item/ItemEnchantments.java @@ -53,8 +53,6 @@ public String getAttribute(Attribute attribute) { return null; } - Set> enchantments = GetEnchantments(); - // <--[tag] // @attribute // @returns Element(Boolean) @@ -64,7 +62,7 @@ public String getAttribute(Attribute attribute) { // Returns whether the item has any enchantments. // --> if (attribute.startsWith("is_enchanted")) { - return new Element(enchantments.size() > 0) + return new Element(getEnchantments().size() > 0) .getAttribute(attribute.fulfill(1)); } @@ -78,6 +76,7 @@ public String getAttribute(Attribute attribute) { // In the format of ENCHANTMENT,LEVEL - For example: DAMAGE_ALL,3 // --> if (attribute.startsWith("enchantments.with_levels")) { + Set> enchantments = getEnchantments(); if (enchantments.size() > 0) { List enchants = new ArrayList(); for (Map.Entry enchantment : enchantments) { @@ -97,6 +96,7 @@ public String getAttribute(Attribute attribute) { // Returns a list of enchantments on the item, showing only the level. // --> if (attribute.startsWith("enchantments.levels")) { + Set> enchantments = getEnchantments(); if (enchantments.size() > 0) { List enchants = new ArrayList(); for (Map.Entry enchantment : enchantments) { @@ -117,6 +117,7 @@ public String getAttribute(Attribute attribute) { // --> if (attribute.startsWith("enchantments.level") && attribute.hasContext(2)) { + Set> enchantments = getEnchantments(); if (enchantments.size() > 0) { for (Map.Entry enchantment : enchantments) { if (enchantment.getKey().getName().equalsIgnoreCase(attribute.getContext(2))) { @@ -138,6 +139,7 @@ public String getAttribute(Attribute attribute) { // Returns a list of enchantments on the item. // --> if (attribute.startsWith("enchantments")) { + Set> enchantments = getEnchantments(); if (enchantments.size() > 0) { List enchants = new ArrayList(); for (Map.Entry enchantment : enchantments) { @@ -151,20 +153,20 @@ public String getAttribute(Attribute attribute) { return null; } - public Set> GetEnchantments() { + public Set> getEnchantments() { if (item.getItemStack().getEnchantments().size() > 0) { return item.getItemStack().getEnchantments().entrySet(); } else if (item.getItemStack().hasItemMeta() && item.getItemStack().getItemMeta() instanceof EnchantmentStorageMeta) { return ((EnchantmentStorageMeta) item.getItemStack().getItemMeta()).getStoredEnchants().entrySet(); } - return new HashSet>(); + return new HashSet<>(); } @Override public String getPropertyString() { - Set> enchants = GetEnchantments(); + Set> enchants = getEnchantments(); if (enchants.size() > 0) { StringBuilder returnable = new StringBuilder(); for (Map.Entry enchantment : enchants) {