Removed @ConfigUpdater

This commit is contained in:
Auxilor 2023-05-15 11:06:45 +01:00
parent efe241cfb2
commit 3a10399e00
6 changed files with 14 additions and 20 deletions

View File

@ -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<Listener> {

View File

@ -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<DisplayableEnchant, List<String>> = Caffeine.newBuilder()
.build()
@JvmStatic
@ConfigUpdater
fun onReload() {
internal fun reload() {
nameCache.invalidateAll()
descriptionCache.invalidateAll()
}

View File

@ -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<EnchantmentSorter>()
@JvmStatic
@ConfigUpdater
fun update(plugin: EcoEnchantsPlugin) {
internal fun reload(plugin: EcoEnchantsPlugin) {
sorters.clear()
if (plugin.configYml.getBool("display.sort.rarity")) {

View File

@ -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<EcoEnchant, Menu>()
@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")

View File

@ -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<TestableItem>()
@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)

View File

@ -3,6 +3,7 @@ options:
bstats-id: 7666
color: "&a"
proxy-package: "com.willfp.ecoenchants.proxy"
uses-reflective-reload: false
environment:
- name: libreforge version