Interface ConfigValue<T>
- Type Parameters:
T- the value's type; values are never null
- All Superinterfaces:
ConfigNode,Supplier<T>
- All Known Implementing Classes:
ConfigValueImpl
One typed setting. Reading is cheap and thread-safe, so keep the handle and call
get() where the value is
used instead of caching it: the value can change through the config screen, a command, the file being edited, or
the server syncing its own.-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(ConfigValue.ChangeListener<T> listener) Called on the thread that changed the value, after it changed.aliases()The old keys (or dotted paths from the root) this value is still read from, for renamed or moved settings.The value this one depends on, if it was built withenabledWhen.get()The current value.The value in the file.default booleanisActive()Whether the dependency, if any, is currently met.default booleandefault booleanWhether a changedConfigScope.STARTUPvalue is waiting for a restart.booleanisSynced()Whether a synced config sends this value to clients.booleanremoveListener(ConfigValue.ChangeListener<T> listener) default voidreset()Sets the default value back.voidChanges the value in memory and notifies listeners;Config.save()writes it.How a syncedConfigScope.STARTUPvalue is reconciled with the server's; ignored by other scopes.type()Checks a value against the type and the entry's own validators, without setting it.Methods inherited from interface net.ixdarklord.coolcatcore.api.config.ConfigNode
comment, config, displayName, isHidden, key, parent, path, translationKey
-
Method Details
-
get
T get()The current value. -
set
Changes the value in memory and notifies listeners;Config.save()writes it. A value the type corrects (a number out of range, say) is stored corrected. AConfigScope.STARTUPvalue only changes its stored value, for the next start.- Throws:
IllegalArgumentException- when the value isn't valid and can't be corrected
-
getStored
T getStored()The value in the file. It equalsget()except for aConfigScope.STARTUPvalue changed since the game started:get()keeps the value the game started with, and this one applies after a restart. -
isRestartPending
default boolean isRestartPending()Whether a changedConfigScope.STARTUPvalue is waiting for a restart. -
validate
Checks a value against the type and the entry's own validators, without setting it. -
getDefault
T getDefault() -
reset
default void reset()Sets the default value back. -
isDefault
default boolean isDefault() -
type
ConfigType<T> type() -
restartRequirement
RestartRequirement restartRequirement() -
isSynced
boolean isSynced()Whether a synced config sends this value to clients. Off for server secrets (a webhook URL, a password), which stay on the server and can't be edited from a client. -
startupSync
StartupSync startupSync()How a syncedConfigScope.STARTUPvalue is reconciled with the server's; ignored by other scopes. -
aliases
The old keys (or dotted paths from the root) this value is still read from, for renamed or moved settings. -
dependency
Optional<ConfigDependency<?>> dependency()The value this one depends on, if it was built withenabledWhen. -
isActive
default boolean isActive()Whether the dependency, if any, is currently met. The config screen greys the value out when it isn't. -
addListener
Called on the thread that changed the value, after it changed. -
removeListener
-