diff --git a/eco-core/core-nms/v1_20_R3/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_20_R3/registration/EcoEnchantsCraftEnchantment.kt b/eco-core/core-nms/v1_20_R3/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_20_R3/registration/EcoEnchantsCraftEnchantment.kt index 59ec007110..5488636a7b 100644 --- a/eco-core/core-nms/v1_20_R3/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_20_R3/registration/EcoEnchantsCraftEnchantment.kt +++ b/eco-core/core-nms/v1_20_R3/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_20_R3/registration/EcoEnchantsCraftEnchantment.kt @@ -23,7 +23,10 @@ class EcoEnchantsCraftEnchantment( } override fun onRegister() { - enchant.onRegister() + // Fix for hardcoded enchantments + if (plugin.isLoaded) { + enchant.onRegister() + } } override fun onRemove() { 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 ee4436e401..ee49ccac30 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 diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/impl/EcoEnchantBase.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/impl/EcoEnchantBase.kt index 69b42c9aed..17d9009f84 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/impl/EcoEnchantBase.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/impl/EcoEnchantBase.kt @@ -1,10 +1,7 @@ package com.willfp.ecoenchants.enchant.impl import com.willfp.eco.core.config.interfaces.Config -import com.willfp.eco.core.fast.fast import com.willfp.eco.core.placeholder.PlayerlessPlaceholder -import com.willfp.eco.core.placeholder.context.PlaceholderContext -import com.willfp.eco.core.placeholder.templates.SimpleInjectablePlaceholder import com.willfp.eco.util.containsIgnoreCase import com.willfp.ecoenchants.EcoEnchantsPlugin import com.willfp.ecoenchants.display.getFormattedName @@ -15,6 +12,7 @@ import com.willfp.ecoenchants.rarity.EnchantmentRarity import com.willfp.ecoenchants.target.EnchantmentTargets import com.willfp.ecoenchants.type.EnchantmentType import com.willfp.ecoenchants.type.EnchantmentTypes +import com.willfp.libreforge.SilentViolationContext import com.willfp.libreforge.ViolationContext import com.willfp.libreforge.conditions.Conditions import org.bukkit.Bukkit @@ -68,7 +66,7 @@ abstract class EcoEnchantBase( override val conditions = Conditions.compile( config.getSubsections("conditions"), - context.with("conditions") + if (plugin.isLoaded) context.with("conditions") else SilentViolationContext ) override val isObtainableThroughEnchanting = config.getBool("enchantable") diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/registration/legacy/LegacyDelegatedEnchantment.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/registration/legacy/LegacyDelegatedEnchantment.kt index f35734e666..dab10cd2be 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/registration/legacy/LegacyDelegatedEnchantment.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/registration/legacy/LegacyDelegatedEnchantment.kt @@ -22,7 +22,10 @@ class LegacyDelegatedEnchantment( } override fun onRegister() { - enchant.onRegister() + // Fix for hardcoded enchantments + if (plugin.isLoaded) { + enchant.onRegister() + } } override fun onRemove() { diff --git a/gradle.properties b/gradle.properties index 4f1716b1fa..5d982fee38 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ #libreforge-updater -#Sun Jan 07 13:52:14 GMT 2024 +#Sat Jan 13 14:24:20 GMT 2024 kotlin.code.style=official -libreforge-version=4.54.0 -version=12.1.0 +libreforge-version=4.55.0 +version=12.2.1