Fixed preloading

This commit is contained in:
Will FP 2024-01-14 15:45:02 +00:00
parent fb6a98faee
commit e8dfce7a00

View File

@ -24,6 +24,8 @@ import org.bukkit.ChatColor
object EcoEnchants : RegistrableCategory<EcoEnchant>("enchant", "enchants") {
private val BY_NAME = HashBiMap.create<String, EcoEnchant>()
override val shouldPreload = true
override fun clear(plugin: LibreforgePlugin) {
plugin as EcoEnchantsPlugin
@ -56,6 +58,26 @@ object EcoEnchants : RegistrableCategory<EcoEnchant>("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