Closed endorh closed 1 year ago
Config reloading is done in the ApplyMode function here: https://github.com/Darkere/ConfigSwapper/blob/c16a6479011660169dc4f4b32612b9c61352061a/src/main/java/com/darkere/configswapper/ModeConfig.java#L198
Oh, my bad, it seems I didn't look deep enough.
Apparently, the error was in the other mod in the end, sorry for the inconvenience 😅
Hey @endorh I got a report that showed the error. I was trying to reflect into the wrong class. At least in 1.19.2 reflection seems to be entirely unnecessary now. See here how you can fire the event: https://github.com/Darkere/ConfigSwapper/blob/4dd28a6ccdd666f14a38f520f3adfa2f6a5838c6/src/main/java/com/darkere/configswapper/ModeConfig.java#L189
I'm glad you could fix it. Thanks for letting me know about the reflection not being necessary anymore, I'll keep it in mind for my next refactor. ^^
Hi, I'm the developer of Simple Config. Recently, someone in my Discord server brought to me an issue around supporting multiple config files to support Zombie Awareness's config setup.
They mentioned they'd tried using your mod to bind a command to some configuration changes, but those changes weren't applying until the next server restart.
In order to help them, I tried quickly checking your mod to see if I could help them get it to work, but I found instead that your mod wasn't reloading the configs properly. Since I already faced this problem when making my own mod, I thought I'd as well let you know how I did it, and why your current implementation doesn't work.
The
/reload
command you use inChangeModeCommand:80
is a vanilla command that reloads datapacks. Unfortunately, it does nothing to reload Forge's config files.What you need to reload Forge's config files is triggering a
ModConfigEvent.Reloading
event for the mod config in question. Unfortunately, this event has a private constructor in Forge (at least it was back in 1.16), so you need to use reflection to trigger it.Feel free to use the approach I used in
SimpleConfigNetworkHandler:203
. The key parts are thetryFireEvent
and thenewReloading
methods. I prepare all the reflection objects necessary in astatic
initializer, but there are many other ways to do it.