EffectiveConfig

abstract class EffectiveConfig

Base class for a plugin's YAML config.

A subclass names its owning plugin (getInstance) and file (getFileName). init copies the bundled default resource on first run and loads it; call it once before reading any values (from onLoad or onEnable — both work, since dataFolder/saveResource are available by then). Typed getters wrap FileConfiguration, and set writes through to disk immediately.

object ExampleConfig : EffectiveConfig() {
override fun getInstance() = ExamplePlugin.instance
override fun getFileName() = "config.yml"
fun getSpawnRadius() = getInt("spawn-radius", 10)
}

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
lateinit var config: FileConfiguration

The loaded configuration; valid after init.

Functions

Link copied to clipboard
fun contains(path: String): Boolean

Whether path exists in the config.

Link copied to clipboard
fun get(path: String): Any?

Raw value at path, or null if absent.

Link copied to clipboard
fun getBoolean(path: String, def: Boolean = false): Boolean

Boolean at path, or def if absent.

Link copied to clipboard

Boolean list at path (empty if absent).

Link copied to clipboard
fun getConfigurationSection(path: String): ConfigurationSection?

Configuration section at path, or null if absent.

Link copied to clipboard
fun getDouble(path: String, def: Double = 0.0): Double

Double at path, or def if absent.

Link copied to clipboard

Double list at path (empty if absent).

Link copied to clipboard
abstract fun getFileName(): String

Config file name inside the plugin's data folder, e.g. "config.yml".

Link copied to clipboard
abstract fun getInstance(): JavaPlugin

The plugin that owns this config (used for data folder and bundled resource).

Link copied to clipboard
fun getInt(path: String, def: Int = 0): Int

Int at path, or def if absent.

Link copied to clipboard

Int list at path (empty if absent).

Link copied to clipboard
fun getList(path: String): List<*>?

Raw list at path, or null if absent.

Link copied to clipboard
fun getLong(path: String, def: Long = 0): Long

Long at path, or def if absent.

Link copied to clipboard

Long list at path (empty if absent).

Link copied to clipboard
fun getString(path: String, def: String? = null): String?

String at path, or def if absent.

Link copied to clipboard

String list at path (empty if absent).

Link copied to clipboard
fun init()

Copies the bundled default (if missing) and loads the config file. Call once before reading values.

Link copied to clipboard
fun set(path: String, value: Any?)

Sets path to value and saves the file immediately.