Class ConfigEvents
java.lang.Object
net.ixdarklord.coolcatcore.api.config.ConfigEvents
Every config's lifecycle, for code watching configs it didn't declare. A config's own listeners
(
Config.addListener(net.ixdarklord.coolcatcore.api.config.Config.ChangeListener), ConfigValue.addListener(net.ixdarklord.coolcatcore.api.config.ConfigValue.ChangeListener<T>)) are usually simpler.
ConfigEvents.LOADED.register(config -> LOGGER.info("Loaded {}", config.id()));
ConfigEvents.RELOADED.register(config -> rebuildCaches());
ConfigEvents.UNLOADING.register(config -> saveWorldState(config));
ConfigEvents.VALUE_CHANGED.register((config, value, oldValue, newValue) -> {
if (value == MyConfig.RENDER_DISTANCE) refreshRenderer();
});
In order, a reload that changes values fires VALUE_CHANGED for each value, then CHANGED once,
then RELOADED. Listeners run on the thread that caused them: the server or client thread for commands,
screens, syncs and hot reloads.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceValues changed, by any means, on the thread that changed them.static interfaceThe file was read for the first time: when the config is registered, or for a world config when a server starts (every time one starts).static interfaceThe file was read again after loading: edited on disk (hot reload), the reload command, orConfig.reload().static interfaceThe file was written.static interfaceClient only: the server's values of a synced config arrived.static interfaceA world config is about to go back to its defaults because its server stopped.static interfaceOne value changed, by any means: set in code, a screen or command, a reload, the server's values arriving, or a reset. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final EventInvoker<ConfigEvents.Changed>static final EventInvoker<ConfigEvents.Loaded>static final EventInvoker<ConfigEvents.Reloaded>static final EventInvoker<ConfigEvents.Saved>static final EventInvoker<ConfigEvents.Synced>static final EventInvoker<ConfigEvents.Unloading>static final EventInvoker<ConfigEvents.ValueChanged> -
Method Summary
-
Field Details
-
LOADED
-
RELOADED
-
UNLOADING
-
VALUE_CHANGED
-
SAVED
-
CHANGED
-
SYNCED
-