From 4ab5e5e9257757283c1fe965a743335a5753d9f6 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Tue, 26 Feb 2019 15:15:43 -0800 Subject: [PATCH] Changing iteration over a nodes children to be based on a list of its children rather than a returned type of String --- .../treasure/ExcavationTreasureConfig.java | 4 ++- .../treasure/FishingTreasureConfig.java | 29 ++++++++++--------- .../treasure/HerbalismTreasureConfig.java | 4 ++- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/config/treasure/ExcavationTreasureConfig.java b/src/main/java/com/gmail/nossr50/config/treasure/ExcavationTreasureConfig.java index f894a1264..ef4fbeb7e 100644 --- a/src/main/java/com/gmail/nossr50/config/treasure/ExcavationTreasureConfig.java +++ b/src/main/java/com/gmail/nossr50/config/treasure/ExcavationTreasureConfig.java @@ -55,7 +55,9 @@ public class ExcavationTreasureConfig extends Config implements UnsafeValueValid } try { - for (String treasureName : excavationTreasureNode.getList(TypeToken.of(String.class))) { + for (ConfigurationNode treasureNode : excavationTreasureNode.getChildrenList()) { + + String treasureName = treasureNode.getString(); //Treasure Material Definition Material treasureMaterial = Material.matchMaterial(treasureName.toUpperCase()); 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 f23bc5522..f7b53f40b 100644 --- a/src/main/java/com/gmail/nossr50/config/treasure/FishingTreasureConfig.java +++ b/src/main/java/com/gmail/nossr50/config/treasure/FishingTreasureConfig.java @@ -85,7 +85,9 @@ public class FishingTreasureConfig extends Config implements UnsafeValueValidati } try { - for (String treasureName : fishingTreasureNode.getList(TypeToken.of(String.class))) { + for (ConfigurationNode treasureNode : fishingTreasureNode.getChildrenList()) { + + String treasureName = treasureNode.getString(); //Treasure Material Definition Material treasureMaterial = Material.matchMaterial(treasureName.toUpperCase()); @@ -190,7 +192,9 @@ public class FishingTreasureConfig extends Config implements UnsafeValueValidati return; try { - for (String treasureName : shakeTreasureNode.getList(TypeToken.of(String.class))) { + for (ConfigurationNode treasureNode : shakeTreasureNode.getChildrenList()) { + + String treasureName = treasureNode.getString(); //Treasure Material Definition Material treasureMaterial = Material.matchMaterial(treasureName.toUpperCase()); @@ -302,21 +306,20 @@ public class FishingTreasureConfig extends Config implements UnsafeValueValidati return; } - try { - for (String enchantmentName : enchantmentSection.getList(TypeToken.of(String.class))) { - int level = getIntValue(ENCHANTMENTS_RARITY, rarity.toString(), enchantmentName); - Enchantment enchantment = EnchantmentUtils.getByName(enchantmentName); + for (ConfigurationNode enchantmentNode : enchantmentSection.getChildrenList()) { - if (enchantment == null) { - mcMMO.p.getLogger().severe("Skipping invalid enchantment in treasures.yml: " + enchantmentName); - continue; - } + String enchantmentName = enchantmentNode.getString(); + int level = getIntValue(ENCHANTMENTS_RARITY, rarity.toString(), enchantmentName); + Enchantment enchantment = EnchantmentUtils.getByName(enchantmentName); - fishingEnchantments.get(rarity).add(new EnchantmentTreasure(enchantment, level)); + if (enchantment == null) { + mcMMO.p.getLogger().severe("Skipping invalid enchantment in treasures.yml: " + enchantmentName); + continue; } - } catch (ObjectMappingException e) { - e.printStackTrace(); + + fishingEnchantments.get(rarity).add(new EnchantmentTreasure(enchantment, level)); } + } } diff --git a/src/main/java/com/gmail/nossr50/config/treasure/HerbalismTreasureConfig.java b/src/main/java/com/gmail/nossr50/config/treasure/HerbalismTreasureConfig.java index 007751979..d35378d7c 100644 --- a/src/main/java/com/gmail/nossr50/config/treasure/HerbalismTreasureConfig.java +++ b/src/main/java/com/gmail/nossr50/config/treasure/HerbalismTreasureConfig.java @@ -58,7 +58,9 @@ public class HerbalismTreasureConfig extends Config implements UnsafeValueValida } try { - for (String treasureName : herbalismTreasureNode.getList(TypeToken.of(String.class))) { + for (ConfigurationNode treasureNode : herbalismTreasureNode.getChildrenList()) { + + String treasureName = treasureNode.getString(); //Treasure Material Definition Material treasureMaterial = Material.matchMaterial(treasureName.toUpperCase());