Interface ConfigRef<T>
- Type Parameters:
T- the config type
- All Superinterfaces:
Supplier<T>
- All Known Implementing Classes:
DefaultConfigRef
A live reference to a config value that updates on reload.
Thread-safe wrapper using volatile + copy-on-write.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(@NotNull Consumer<T> listener) Adds a listener for config changes.get()Gets the current config value.Gets the config class this ref wraps.booleanisLoaded()Checks if the config has been loaded at least once.voidreload()Forces a reload of this config.voidremoveListener(@NotNull Consumer<T> listener) Removes a previously added listener.
-
Method Details
-
get
Gets the current config value. -
addListener
Adds a listener for config changes.- Parameters:
listener- the listener to add
-
removeListener
Removes a previously added listener.- Parameters:
listener- the listener to remove
-
isLoaded
boolean isLoaded()Checks if the config has been loaded at least once.- Returns:
- true if loaded
-
reload
void reload()Forces a reload of this config. -
getConfigClass
Gets the config class this ref wraps.- Returns:
- the config class
-