Config
YAML configuration with type safety and enum-based patterns
Unify wraps Bukkit's FileConfiguration with a simpler, safer API.
Basic Usage
import me.jordanfails.unify.Config
class MyPlugin : JavaPlugin() {
lateinit var config: Config
override fun onEnable() {
config = Config(this, "config")
val prefix = config.getString("prefix", "&8[&bPlugin&8] ")
val maxPlayers = config.getInt("max-players", 10)
val debug = config.getBoolean("debug", false)
}
}Creating Default Configs
// Creates config.yml in your plugin folder
// Copies from resources/config.yml if it exists
val config = Config(this, "config")
// Creates shops/shops.yml
val shops = Config(this, "shops/shops")Type-Safe Access
| Method | Default | Returns |
|---|---|---|
getString(path, default) | "" | String |
getInt(path, default) | 0 | Int |
getDouble(path, default) | 0.0 | Double |
getBoolean(path, default) | false | Boolean |
getStringList(path) | emptyList() | List<String> |
getSection(path) | — | ConfigurationSection? |
Saving & Reloading
config.set("player-data.kills", kills)
config.save()
config.reload()