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 8b205344..2d5da896 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 @@ -21,7 +21,7 @@ public class EnchantmentRarity { private static final Set REGISTERED = new HashSet<>(); static { - update(); + update(EcoEnchantsPlugin.getInstance()); } /** @@ -94,8 +94,8 @@ public class EnchantmentRarity { * Update all rarities. */ @ConfigUpdater - public static void update() { - RarityYml rarityYml = EcoEnchantsPlugin.getInstance().getRarityYml(); + public static void update(@NotNull final EcoEnchantsPlugin plugin) { + RarityYml rarityYml = plugin.getRarityYml(); List raritiesNames = rarityYml.getRarities(); raritiesNames.forEach(rarity -> { double probability = rarityYml.getDouble("rarities." + rarity + ".table-probability"); 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 92280e0c..6e4d92e5 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 @@ -25,7 +25,7 @@ public class EnchantmentTarget { static { REGISTERED.add(ALL); - update(); + update(EcoEnchantsPlugin.getInstance()); } /** @@ -67,11 +67,11 @@ public class EnchantmentTarget { * Update all targets. */ @ConfigUpdater - public static void update() { - List targetNames = EcoEnchantsPlugin.getInstance().getTargetYml().getTargets(); + public static void update(@NotNull final EcoEnchantsPlugin plugin) { + List targetNames = plugin.getTargetYml().getTargets(); ALL.materials.clear(); targetNames.forEach(name -> { - Set materials = EcoEnchantsPlugin.getInstance().getTargetYml().getTargetMaterials(name); + Set materials = plugin.getTargetYml().getTargetMaterials(name); new EnchantmentTarget(name, materials).register(); }); } diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/vanilla/VanillaEnchantments.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/vanilla/VanillaEnchantments.java index f75cc973..32ff836b 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/vanilla/VanillaEnchantments.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/vanilla/VanillaEnchantments.java @@ -1,11 +1,13 @@ package com.willfp.ecoenchants.enchantments.support.vanilla; +import com.willfp.eco.core.EcoPlugin; import com.willfp.ecoenchants.EcoEnchantsPlugin; import com.willfp.ecoenchants.proxy.proxies.EcoCraftEnchantmentManagerProxy; import com.willfp.ecoenchants.util.ProxyUtils; import lombok.experimental.UtilityClass; import org.bukkit.NamespacedKey; import org.bukkit.enchantments.Enchantment; +import org.jetbrains.annotations.NotNull; import java.util.Arrays; import java.util.HashMap; @@ -15,11 +17,6 @@ import java.util.stream.Collectors; @UtilityClass public class VanillaEnchantments { - /** - * Instance of EcoEnchants. - */ - private static final EcoEnchantsPlugin PLUGIN = EcoEnchantsPlugin.getInstance(); - /** * Vanilla Enchantment Metadata Map. */ @@ -37,14 +34,14 @@ public class VanillaEnchantments { /** * Update the map. */ - public static void update() { + public static void update(@NotNull final EcoEnchantsPlugin plugin) { Map map = new HashMap<>(); List enchantments = Arrays.stream(Enchantment.values()) .filter(enchantment -> enchantment.getClass().getName().contains("CraftEnchantment")) .collect(Collectors.toList()); - Map maxLevels = PLUGIN.getVanillaEnchantsYml().getStrings("max-levels").stream() + Map maxLevels = plugin.getVanillaEnchantsYml().getStrings("max-levels").stream() .collect(Collectors.toMap( s -> Enchantment.getByKey(NamespacedKey.minecraft(s.split(":")[0].toLowerCase())), s1 -> Integer.parseInt(s1.split(":")[1]) @@ -59,7 +56,7 @@ public class VanillaEnchantments { MAP.clear(); MAP.putAll(map); - if (PLUGIN.getVanillaEnchantsYml().getBool("enabled")) { + if (plugin.getVanillaEnchantsYml().getBool("enabled")) { ProxyUtils.getProxy(EcoCraftEnchantmentManagerProxy.class).registerNewCraftEnchantments(); } } diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/WatcherTriggers.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/WatcherTriggers.java index aaff7e85..c817d7da 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/WatcherTriggers.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/WatcherTriggers.java @@ -53,8 +53,8 @@ public class WatcherTriggers extends PluginDependent implements Listener { * Update if allowed on npc. */ @ConfigUpdater - public static void update() { - allowOnNPC = EcoEnchantsPlugin.getInstance().getConfig().getBoolean("allow-on-npc"); + public static void update(@NotNull final EcoEnchantsPlugin plugin) { + allowOnNPC = plugin.getConfig().getBoolean("allow-on-npc"); } /**