From e8dfce7a00d1e97b26878eef419b650d03012dd2 Mon Sep 17 00:00:00 2001 From: Will FP Date: Sun, 14 Jan 2024 15:45:02 +0000 Subject: [PATCH] Fixed preloading --- .../willfp/ecoenchants/enchant/EcoEnchants.kt | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/EcoEnchants.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/EcoEnchants.kt index ee4436e4..ee49ccac 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/EcoEnchants.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/EcoEnchants.kt @@ -24,6 +24,8 @@ import org.bukkit.ChatColor object EcoEnchants : RegistrableCategory("enchant", "enchants") { private val BY_NAME = HashBiMap.create() + override val shouldPreload = true + override fun clear(plugin: LibreforgePlugin) { plugin as EcoEnchantsPlugin @@ -56,6 +58,26 @@ object EcoEnchants : RegistrableCategory("enchant", "enchants") { registerHardcodedEnchantments(plugin) } + override fun acceptPreloadConfig(plugin: LibreforgePlugin, id: String, config: Config) { + plugin as EcoEnchantsPlugin + + if (!config.has("effects")) { + return + } + + try { + val enchant = LibreforgeEcoEnchant( + id, + config, + plugin + ) + + doRegister(plugin, enchant) + } catch (e: MissingDependencyException) { + // Ignore missing dependencies for preloaded enchants + } + } + override fun acceptConfig(plugin: LibreforgePlugin, id: String, config: Config) { plugin as EcoEnchantsPlugin