From 2f804de36fb3718dcfe494f985e8f1ebb59375a9 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Mon, 25 Feb 2019 14:55:26 -0800 Subject: [PATCH] fishing treasures pt 4 (enchantments) --- .../treasure/FishingTreasureConfig.java | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/config/treasure/FishingTreasureConfig.java b/src/main/java/com/gmail/nossr50/config/treasure/FishingTreasureConfig.java index 174da2e4b..e262d0a09 100644 --- a/src/main/java/com/gmail/nossr50/config/treasure/FishingTreasureConfig.java +++ b/src/main/java/com/gmail/nossr50/config/treasure/FishingTreasureConfig.java @@ -293,22 +293,27 @@ public class FishingTreasureConfig extends Config implements UnsafeValueValidati fishingEnchantments.put(rarity, (new ArrayList())); } - ConfigurationSection enchantmentSection = config.getConfigurationSection(ENCHANTMENTS_RARITY, rarity.toString()); + ConfigurationNode enchantmentSection = getUserRootNode().getNode(ENCHANTMENTS_RARITY, rarity.toString()); if (enchantmentSection == null) { + mcMMO.p.getLogger().info("No enchantment information for fishing treasures, is this intentional?"); return; } - for (String enchantmentName : enchantmentSection.getKeys(false)) { - int level = getIntValue(ENCHANTMENTS_RARITY, rarity.toString(), enchantmentName); - Enchantment enchantment = EnchantmentUtils.getByName(enchantmentName); + try { + for (String enchantmentName : enchantmentSection.getList(TypeToken.of(String.class))) { + int level = getIntValue(ENCHANTMENTS_RARITY, rarity.toString(), enchantmentName); + Enchantment enchantment = EnchantmentUtils.getByName(enchantmentName); - if (enchantment == null) { - plugin.getLogger().warning("Skipping invalid enchantment in treasures.yml: " + enchantmentName); - continue; + if (enchantment == null) { + mcMMO.p.getLogger().severe("Skipping invalid enchantment in treasures.yml: " + enchantmentName); + continue; + } + + fishingEnchantments.get(rarity).add(new EnchantmentTreasure(enchantment, level)); } - - fishingEnchantments.get(rarity).add(new EnchantmentTreasure(enchantment, level)); + } catch (ObjectMappingException e) { + e.printStackTrace(); } } }