From a27a8fa1d2c7459955b6cf50597ff53082e176a4 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Fri, 2 Apr 2021 12:42:22 +0100 Subject: [PATCH] Updated to eco 4.3.1 configs --- .../config/configs/EnchantmentConfig.java | 12 ++++++------ .../willfp/ecoenchants/config/configs/Rarity.java | 6 +++--- .../willfp/ecoenchants/config/configs/Target.java | 7 ++++--- .../enchantments/meta/EnchantmentRarity.java | 3 ++- .../enchantments/meta/EnchantmentTarget.java | 3 ++- 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/configs/EnchantmentConfig.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/configs/EnchantmentConfig.java index 222785cb..6c74e44f 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/configs/EnchantmentConfig.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/configs/EnchantmentConfig.java @@ -46,7 +46,7 @@ public class EnchantmentConfig extends ExtendableConfig { */ public Set getEnchantments(@NotNull final String path) { Set enchantments = new HashSet<>(); - List enchantmentKeys = this.getConfig().getStringList(path); + List enchantmentKeys = this.getStrings(path); enchantmentKeys.forEach((key -> enchantments.add(Enchantment.getByKey(NamespacedKey.minecraft(key))))); return enchantments; } @@ -67,7 +67,7 @@ public class EnchantmentConfig extends ExtendableConfig { * @return The targets. */ public Set getTargets() { - List targetNames = this.getConfig().getStringList(EcoEnchants.GENERAL_LOCATION + "targets"); + List targetNames = this.getStrings(EcoEnchants.GENERAL_LOCATION + "targets"); if (targetNames.isEmpty()) { return new HashSet<>(); } @@ -88,14 +88,14 @@ public class EnchantmentConfig extends ExtendableConfig { * Load config values from lang.yml. */ public void loadFromLang() { - if (!this.getPlugin().getLangYml().getConfig().contains("enchantments." + this.getName())) { + if (!this.getPlugin().getLangYml().has("enchantments." + this.getName())) { return; } - this.getConfig().set("name", this.getPlugin().getLangYml().getString("enchantments." + this.getName() + ".name")); - this.getConfig().set("description", this.getPlugin().getLangYml().getString("enchantments." + this.getName() + ".description")); + this.config.set("name", this.getPlugin().getLangYml().getString("enchantments." + this.getName() + ".name")); + this.config.set("description", this.getPlugin().getLangYml().getString("enchantments." + this.getName() + ".description")); try { - this.getConfig().save(this.getConfigFile()); + this.config.save(this.getConfigFile()); } catch (IOException e) { e.printStackTrace(); } diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/configs/Rarity.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/configs/Rarity.java index d43364ff..fa9f47ad 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/configs/Rarity.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/configs/Rarity.java @@ -3,7 +3,7 @@ package com.willfp.ecoenchants.config.configs; import com.willfp.eco.util.config.BaseConfig; import com.willfp.ecoenchants.EcoEnchantsPlugin; -import java.util.Set; +import java.util.List; public class Rarity extends BaseConfig { /** @@ -18,7 +18,7 @@ public class Rarity extends BaseConfig { * * @return Set of all rarity names. */ - public Set getRarities() { - return this.getConfig().getConfigurationSection("rarities").getKeys(false); + public List getRarities() { + return this.getSubsection("rarities").getKeys(false); } } diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/configs/Target.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/configs/Target.java index c603c94f..a7ea1076 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/configs/Target.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/configs/Target.java @@ -6,6 +6,7 @@ import org.bukkit.Material; import org.jetbrains.annotations.NotNull; import java.util.HashSet; +import java.util.List; import java.util.Set; public class Target extends BaseConfig { @@ -21,8 +22,8 @@ public class Target extends BaseConfig { * * @return Set of all names. */ - public Set getTargets() { - return this.getConfig().getConfigurationSection("targets").getKeys(false); + public List getTargets() { + return this.getSubsection("targets").getKeys(false); } /** @@ -33,7 +34,7 @@ public class Target extends BaseConfig { */ public Set getTargetMaterials(@NotNull final String target) { Set materials = new HashSet<>(); - this.getConfig().getStringList("targets." + target).forEach(materialName -> { + this.getStrings("targets." + target).forEach(materialName -> { materials.add(Material.getMaterial(materialName.toUpperCase())); }); diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/meta/EnchantmentRarity.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/meta/EnchantmentRarity.java index 569624af..8bca78b7 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/meta/EnchantmentRarity.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/meta/EnchantmentRarity.java @@ -11,6 +11,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.HashSet; +import java.util.List; import java.util.Objects; import java.util.Optional; import java.util.Set; @@ -151,7 +152,7 @@ public class EnchantmentRarity { */ @ConfigUpdater public static void update() { - Set raritiesNames = EcoEnchantsConfigs.RARITY.getRarities(); + List raritiesNames = EcoEnchantsConfigs.RARITY.getRarities(); raritiesNames.forEach(rarity -> { double probability = EcoEnchantsConfigs.RARITY.getDouble("rarities." + rarity + ".table-probability"); int minimumLevel = EcoEnchantsConfigs.RARITY.getInt("rarities." + rarity + ".minimum-level"); diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/meta/EnchantmentTarget.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/meta/EnchantmentTarget.java index e0669657..d9a405bc 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/meta/EnchantmentTarget.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/meta/EnchantmentTarget.java @@ -8,6 +8,7 @@ import org.bukkit.Material; import org.jetbrains.annotations.NotNull; import java.util.HashSet; +import java.util.List; import java.util.Objects; import java.util.Optional; import java.util.Set; @@ -72,7 +73,7 @@ public class EnchantmentTarget { */ @ConfigUpdater public static void update() { - Set targetNames = EcoEnchantsConfigs.TARGET.getTargets(); + List targetNames = EcoEnchantsConfigs.TARGET.getTargets(); ALL.materials.clear(); targetNames.forEach(name -> { Set materials = EcoEnchantsConfigs.TARGET.getTargetMaterials(name);