Fix reload command not executing the config event.

Also lazy loading of config guis.
This commit is contained in:
alexcrea 2024-07-23 04:08:55 +02:00
parent e39bee5952
commit 03ae19e8a7
No known key found for this signature in database
GPG key ID: 43FD265DB0DBF91F
10 changed files with 109 additions and 32 deletions

View file

@ -128,6 +128,10 @@ class CustomAnvil : JavaPlugin() {
// temporary: handle 1.21 update
Update_1_21.handleUpdate()
// Register enchantment of compatible plugin and load configuration change.
DependencyManager.handleCompatibilityConfig()
// Call config event
val configReadyEvent = CAConfigReadyEvent()
server.pluginManager.callEvent(configReadyEvent)
@ -135,8 +139,6 @@ class CustomAnvil : JavaPlugin() {
MainConfigGui.getInstance().init(DependencyManager.packetManager)
GuiSharedConstant.loadConstants()
// Register enchantment of compatible plugin and load configuration change.
DependencyManager.handleCompatibilityConfig()
}
fun reloadResource(

View file

@ -1,11 +1,15 @@
package xyz.alexcrea.cuanvil.command
import io.delilaheve.CustomAnvil
import org.bukkit.Bukkit
import org.bukkit.command.Command
import org.bukkit.command.CommandExecutor
import org.bukkit.command.CommandSender
import xyz.alexcrea.cuanvil.api.event.CAConfigReadyEvent
import xyz.alexcrea.cuanvil.config.ConfigHolder
import xyz.alexcrea.cuanvil.dependency.DependencyManager
import xyz.alexcrea.cuanvil.gui.config.global.*
import xyz.alexcrea.cuanvil.update.Update_1_21
class ReloadExecutor : CommandExecutor {
override fun onCommand(sender: CommandSender, cmd: Command, cmdstr: String, args: Array<out String>): Boolean {
@ -39,10 +43,20 @@ class ReloadExecutor : CommandExecutor {
EnchantCostConfigGui.getInstance()?.updateGuiValues()
EnchantLimitConfigGui.getInstance()?.updateGuiValues()
EnchantConflictGui.INSTANCE.reloadValues()
GroupConfigGui.INSTANCE.reloadValues()
UnitRepairConfigGui.INSTANCE.reloadValues()
CustomRecipeConfigGui.INSTANCE.reloadValues()
EnchantConflictGui.getCurrentInstance()?.reloadValues()
GroupConfigGui.getCurrentInstance()?.reloadValues()
UnitRepairConfigGui.getCurrentInstance()?.reloadValues()
CustomRecipeConfigGui.getCurrentInstance()?.reloadValues()
// temporary: handle 1.21 update
Update_1_21.handleUpdate()
// Register enchantment of compatible plugin and load configuration change.
DependencyManager.handleCompatibilityConfig()
// Call event
val configReadyEvent = CAConfigReadyEvent()
Bukkit.getServer().pluginManager.callEvent(configReadyEvent)
return true
} catch (e: Exception) {