diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/EcoEnchantsPlugin.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/EcoEnchantsPlugin.kt index f7a4c50c..b646506c 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/EcoEnchantsPlugin.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/EcoEnchantsPlugin.kt @@ -9,9 +9,12 @@ import com.willfp.ecoenchants.config.RarityYml import com.willfp.ecoenchants.config.TargetsYml import com.willfp.ecoenchants.config.TypesYml import com.willfp.ecoenchants.config.VanillaEnchantsYml +import com.willfp.ecoenchants.display.DisplayCache import com.willfp.ecoenchants.display.EnchantDisplay +import com.willfp.ecoenchants.display.EnchantSorter import com.willfp.ecoenchants.enchants.EcoEnchantLevel import com.willfp.ecoenchants.enchants.EcoEnchants +import com.willfp.ecoenchants.enchants.EnchantGUI import com.willfp.ecoenchants.enchants.LoreConversion import com.willfp.ecoenchants.enchants.registerVanillaEnchants import com.willfp.ecoenchants.integrations.EnchantRegistrations @@ -19,6 +22,7 @@ import com.willfp.ecoenchants.integrations.plugins.CMIIntegration import com.willfp.ecoenchants.integrations.plugins.EssentialsIntegration import com.willfp.ecoenchants.mechanics.AnvilSupport import com.willfp.ecoenchants.mechanics.EnchantingTableSupport +import com.willfp.ecoenchants.mechanics.ExtraItemSupport import com.willfp.ecoenchants.mechanics.GrindstoneSupport import com.willfp.ecoenchants.mechanics.LootSupport import com.willfp.ecoenchants.mechanics.VillagerSupport @@ -67,6 +71,11 @@ class EcoEnchantsPlugin : LibreforgePlugin() { override fun handleReload() { registerVanillaEnchants(this) + + DisplayCache.reload() + EnchantSorter.reload(this) + ExtraItemSupport.reload(this) + EnchantGUI.reload(this) } override fun loadListeners(): List { diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/display/EnchantmentFormatting.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/display/EnchantmentFormatting.kt index bfc41276..7f9b4396 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/display/EnchantmentFormatting.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/display/EnchantmentFormatting.kt @@ -8,10 +8,6 @@ import com.willfp.eco.util.StringUtils import com.willfp.eco.util.formatEco import com.willfp.ecoenchants.EcoEnchantsPlugin import com.willfp.ecoenchants.enchants.EcoEnchantLike -import net.kyori.adventure.text.Component -import net.kyori.adventure.text.JoinConfiguration -import net.kyori.adventure.text.TextComponent -import java.util.stream.Collectors // This is an object to be able to invalidate the cache on reload object DisplayCache { @@ -21,9 +17,7 @@ object DisplayCache { val descriptionCache: Cache> = Caffeine.newBuilder() .build() - @JvmStatic - @ConfigUpdater - fun onReload() { + internal fun reload() { nameCache.invalidateAll() descriptionCache.invalidateAll() } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/display/Sorters.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/display/Sorters.kt index 2c1901b2..6f6d4411 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/display/Sorters.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/display/Sorters.kt @@ -1,6 +1,5 @@ package com.willfp.ecoenchants.display -import com.willfp.eco.core.config.updating.ConfigUpdater import com.willfp.ecoenchants.EcoEnchantsPlugin import com.willfp.ecoenchants.enchants.wrap import com.willfp.ecoenchants.rarity.EnchantmentRarities @@ -17,9 +16,7 @@ interface EnchantmentSorter { object EnchantSorter { private val sorters = mutableListOf() - @JvmStatic - @ConfigUpdater - fun update(plugin: EcoEnchantsPlugin) { + internal fun reload(plugin: EcoEnchantsPlugin) { sorters.clear() if (plugin.configYml.getBool("display.sort.rarity")) { diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/EnchantGUI.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/EnchantGUI.kt index 9ff73c73..f0cbf8dc 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/EnchantGUI.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/EnchantGUI.kt @@ -2,7 +2,6 @@ package com.willfp.ecoenchants.enchants import com.github.benmanes.caffeine.cache.Caffeine import com.willfp.eco.core.config.base.LangYml -import com.willfp.eco.core.config.updating.ConfigUpdater import com.willfp.eco.core.drops.DropQueue import com.willfp.eco.core.fast.fast import com.willfp.eco.core.gui.GUIComponent @@ -22,7 +21,6 @@ import com.willfp.eco.core.items.builder.ItemStackBuilder import com.willfp.eco.core.items.isEmpty import com.willfp.eco.util.StringUtils import com.willfp.eco.util.formatEco -import com.willfp.eco.util.toNiceString import com.willfp.ecoenchants.EcoEnchantsPlugin import com.willfp.ecoenchants.display.EnchantSorter.sortForDisplay import com.willfp.ecoenchants.display.getFormattedName @@ -39,9 +37,7 @@ object EnchantGUI { private lateinit var menu: Menu private val enchantInfoMenus = Caffeine.newBuilder().build() - @JvmStatic - @ConfigUpdater - fun update(plugin: EcoEnchantsPlugin) { + internal fun reload(plugin: EcoEnchantsPlugin) { menu = menu(plugin.configYml.getInt("enchant-gui.rows")) { title = plugin.configYml.getFormattedString("enchant-gui.title") diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/mechanics/EnchantingTableSupport.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/mechanics/EnchantingTableSupport.kt index a868ab72..d1291f09 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/mechanics/EnchantingTableSupport.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/mechanics/EnchantingTableSupport.kt @@ -1,6 +1,5 @@ package com.willfp.ecoenchants.mechanics -import com.willfp.eco.core.config.updating.ConfigUpdater import com.willfp.eco.core.items.Items import com.willfp.eco.core.items.TestableItem import com.willfp.eco.core.recipe.parts.EmptyTestableItem @@ -233,9 +232,7 @@ object ExtraItemSupport { internal val extraEnchantableItems = mutableListOf() - @JvmStatic - @ConfigUpdater - fun reload(plugin: EcoEnchantsPlugin) { + internal fun reload(plugin: EcoEnchantsPlugin) { extraEnchantableItems.clear() extraEnchantableItems.addAll(plugin.targetsYml.getStrings("extra-enchantable-items").map { Items.lookup(it) diff --git a/eco-core/core-plugin/src/main/resources/eco.yml b/eco-core/core-plugin/src/main/resources/eco.yml index fa10d335..2ba2a4ea 100644 --- a/eco-core/core-plugin/src/main/resources/eco.yml +++ b/eco-core/core-plugin/src/main/resources/eco.yml @@ -3,6 +3,7 @@ options: bstats-id: 7666 color: "&a" proxy-package: "com.willfp.ecoenchants.proxy" + uses-reflective-reload: false environment: - name: libreforge version