ref

inline fun <T : Any> ref(file: File): ConfigRef<T>

Creates a live ConfigRef for the given configuration type and file.

A ConfigRef is a reload-safe wrapper: any class holding a ConfigRef always sees the latest config after a reload, without re-injection.

// In plugin onEnable:
val configRef = YamlConfigManager.ref<DuelsConfig>(dataFolder.resolve("config.yml"))
.withAutoReload()
.onChange { old, new -> logger.info("Config reloaded") }

// Pass to managers — they never hold stale references:
val duelManager = DuelManager(configRef)
val queueManager = QueueManager(configRef)

Return

A ConfigRef wrapping the loaded config.

Since

1.0

Parameters

T

The configuration data class type.

file

The YAML file to load and track.

See also