Fix reloading event firing during server shutdown and add explicit unloading event instead (#9016)

This commit is contained in:
cpw authored and GitHub committed 2023-02-06 13:30:16 -08:00
1 parent 57fd0ecb2e
commit 50f325c8fe
5 files changed
+42 -4

No files matched your search

@@ -22,15 +22,37 @@ public class ModConfigEvent extends Event implements IModBusEvent, IConfigEvent
return config;
}
/**
* Fired during mod and server loading, depending on {@link ModConfig.Type} of config file.
* Any Config objects associated with this will be valid and can be queried directly.
*/
public static class Loading extends ModConfigEvent {
public Loading(final ModConfig config) {
super(config);
}
}
/**
* Fired when the configuration is changed. This can be caused by a change to the config
* from a UI or from editing the file itself. IMPORTANT: this can fire at any time
* and may not even be on the server or client threads. Ensure you properly synchronize
* any resultant changes.
*/
public static class Reloading extends ModConfigEvent {
public Reloading(final ModConfig config) {
super(config);
}
}
/**
* Fired when a config is unloaded. This only happens when the server closes, which is
* probably only really relevant on the client, to reset internal mod state when the
* server goes away, though it will fire on the dedicated server as well.
* The config file will be saved after this event has fired.
*/
public static class Unloading extends ModConfigEvent {
public Unloading(final ModConfig config) {
super(config);
}
}
}