Config

class Config(val file: File, val internalConfig: YamlConfiguration = YamlConfiguration.loadConfiguration(file)) : ConfigSection(source)

Wraps a config file and provides useful facilities for writing/reading it.

If the file changes on disk, you will need to create a new Config object to get the latest version of the file.

Constructors

Link copied to clipboard
constructor(path: Path)
constructor(plugin: Plugin, path: String)
constructor(file: File, internalConfig: YamlConfiguration = YamlConfiguration.loadConfiguration(file))

Properties

Link copied to clipboard
val file: File
Link copied to clipboard

The YamlConfiguration that this object wraps.

Link copied to clipboard
Link copied to clipboard

Returns all the keys in the section.

Functions

Link copied to clipboard
Link copied to clipboard
fun <T> get(key: String, adapter: ConfigAdapter<T>): T?

Returns null if the key does not exist or if the value cannot be converted to the desired type.

fun <T> get(key: String, adapter: ConfigAdapter<T>, defaultValue: T): T

Returns defaultValue if the key does not exist or if the value cannot be converted to the desired type.

Link copied to clipboard
fun <T> getOrThrow(key: String, adapter: ConfigAdapter<T>): T

Throws an error if the key does not exist or if the value cannot be converted to the desired type.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Gets all the values in the section that are themselves sections.

Link copied to clipboard
fun merge(other: ConfigSection)

'Merges' other with this ConfigSection by copying all of its keys into this ConfigSection. If a key exists in both section, this ConfigSection's keys take priority.

Link copied to clipboard
fun save()

Saves the configuration to the file it was loaded from.

Link copied to clipboard
fun <T> set(key: String, value: T)