AbstractConfig

abstract class AbstractConfig

Base class for any plugin configuration to extend. It provides the config methods to create property delegates. Example usage:

    class Configuration(plugin: Plugin): AbstractConfig(wrapConfig(plugin)) {
val value1: String by config("path1", default = "default value")
val value2: Int by config("path2.subpath2", default = 11)
val value3: List<Material> by config("path3", default = listOf(DIRT, GRASS, STONE)
val value4: CustomObject by config("path4", default = CustomObject("object"),
serialize = CustomObject::toString(),
deserialize = { CustomObject(it.toLowerCase()) }
)
}

It also provides methods to save defaults saveDefaults and reload config values reloadConfig

Types

Link copied to clipboard
inner class ConfigDelegate<T>(path: String, producer: (String) -> T, consumer: (String, T) -> Unit, comments: List<String> = emptyList())

A property delegate for storage in a backing ConfigWrapper. See AbstractConfig for usage.

Link copied to clipboard
interface ConfigWrapper

An abstraction for an underlying configuration store. Decouples config delegates from the underlying config framework.

Functions

Link copied to clipboard

Reloads all config values. Invokes the provided ConfigWrapper.reloadConfig.

Link copied to clipboard

Removes any keys from the configuration that are not associated with any registered delegate. This helps keeping the configuration file clean from legacy settings.

Link copied to clipboard
fun save()

Writes any changes in configuration values to disk. WARNING: overwrites any changes done to the config file on disk!

Link copied to clipboard

Writes all provided default values to the underlying config store and reloads the updated config values.