Class Config
java.lang.Object
com.github.darksoulq.abyssallib.common.config.Config
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassRepresents a specific value within the configuration. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddComment(String path, String... commentLines) Associates one or more comment lines with a configuration path.voidreload()Reloads the configuration from the disk.voidsave()Saves the current configuration state to the disk and injects defined comments.<T> Config.Value<T> Defines a configuration value with a default fallback.<T> Config.Value<T> Defines a configuration value that requires aCodecfor serialization.
-
Constructor Details
-
Config
Constructs a new Config instance located in a subfolder.- Parameters:
pluginId- The ID/name of the plugin (used for the root folder).name- The name of the YAML file (without extension).subfolder- The subfolder within the plugin's config directory.
-
Config
-
-
Method Details
-
value
Defines a configuration value with a default fallback.- Type Parameters:
T- The type of the value.- Parameters:
path- The YAML path (e.g., "settings.enabled").defaultValue- The value to use and save if the path does not exist.- Returns:
- A
Config.Valueobject to interact with this configuration node.
-
value
Defines a configuration value that requires aCodecfor serialization.- Type Parameters:
T- The type of the value.- Parameters:
path- The YAML path.defaultValue- The default value fallback.codec- The codec used to encode/decode the value.- Returns:
- A
Config.Valueobject.
-
addComment
-
save
public void save()Saves the current configuration state to the disk and injects defined comments.- Throws:
RuntimeException- If anIOExceptionoccurs during saving.
-
reload
public void reload()Reloads the configuration from the disk.- Throws:
RuntimeException- If the file is invalid or inaccessible.
-