diff --git a/api/src/main/java/xyz/srnyx/annoyingapi/file/AnnoyingFile.java b/api/src/main/java/xyz/srnyx/annoyingapi/file/AnnoyingFile.java index 316ffac..40ccccb 100644 --- a/api/src/main/java/xyz/srnyx/annoyingapi/file/AnnoyingFile.java +++ b/api/src/main/java/xyz/srnyx/annoyingapi/file/AnnoyingFile.java @@ -261,18 +261,7 @@ public ItemStack getItemStack(@NotNull String path, @Nullable ItemStack def) { // Material, amount, and durability final ItemStack item = new ItemStack(material, section.getInt("amount", 1), (short) section.getInt("damage", 0)); - // Enchantments - final ConfigurationSection enchantmentsSection = section.getConfigurationSection("enchantments"); - if (enchantmentsSection != null) for (final String enchantmentKey : enchantmentsSection.getKeys(false)) { - final Enchantment enchantment = Enchantment.getByName(enchantmentKey); - if (enchantment == null) { - log(Level.WARNING, path, "&cInvalid enchantment: &4" + enchantmentKey); - continue; - } - item.addUnsafeEnchantment(enchantment, enchantmentsSection.getInt(enchantmentKey)); - } - - // Name, lore, unbreakable, flags, attribute modifiers, and custom model data + // Name, lore, unbreakable, enchantments, flags, attribute modifiers, and custom model data final ItemMeta meta = item.getItemMeta(); if (meta != null) { // Name @@ -287,6 +276,17 @@ public ItemStack getItemStack(@NotNull String path, @Nullable ItemStack def) { // Unbreakable meta.setUnbreakable(section.getBoolean("unbreakable", false)); + // Enchantments + final ConfigurationSection enchantmentsSection = section.getConfigurationSection("enchantments"); + if (enchantmentsSection != null) for (final String enchantmentKey : enchantmentsSection.getKeys(false)) { + final Enchantment enchantment = Enchantment.getByName(enchantmentKey); + if (enchantment == null) { + log(Level.WARNING, path, "&cInvalid enchantment: &4" + enchantmentKey); + continue; + } + meta.addEnchant(enchantment, enchantmentsSection.getInt(enchantmentKey), true); + } + // Flags section.getStringList("flags").stream() .map(string -> {