getConfigInstance
Loads and returns the plugin's configuration as an instance of type C.
This extension function is a convenient shorthand for calling Configs.load with this plugin instance. It automatically loads the "config.yml" file from the plugin's data folder and maps it to the specified configuration class type using reflection.
The configuration class C should be a data class with properties matching the structure of the YAML file. Default values in the data class constructor will be used for any missing fields in the config.
Return
an instance of type C populated with data from the plugin's config.yml
Parameters
C
the type of the configuration class to load
See also
Example usage:
data class MyConfig(val enabled: Boolean = true, val message: String = "Hello")
class MyPlugin : JavaPlugin() {
lateinit var config: MyConfig
override fun onEnable() {
saveDefaultConfig()
config = getConfigInstance()
}
}Content copied to clipboard