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(Config.ChangeListener), ConfigValue.addListener(ConfigValue.ChangeListener)) are usually simpler.
ConfigEvents.LOADED.register(config -> LOGGER.info("Loaded {}", config.id()));
ConfigEvents.RELOADED.register(config -> rebuildCaches());
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.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 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.ValueChanged> -
Method Summary
-
Field Details
-
LOADED
-
RELOADED
-
VALUE_CHANGED
-
SAVED
-
CHANGED
-
SYNCED
-