Config Files
DzusillCore uses a custom Config class that extends Bukkitβs YamlConfiguration with two important extras: comment preservation and automatic sync of new keys from bundled resources.
How it works
Section titled βHow it worksβWhen Config.loadConfig() is called, it:
- Copies the bundled resource file to the pluginβs data folder if the on-disk file doesnβt exist.
- Loads the on-disk YAML into memory.
- Syncs any keys present in the bundled resource but missing from the on-disk file (so new defaults appear after an update without overwriting user edits).
- Preserves comments from the bundled resource.
Loading a raw config
Section titled βLoading a raw configβConfig config = Config.loadConfig(plugin, "data.yml", "data.yml");// or with sections to ignore during sync:Config config = Config.loadConfig(plugin, "data.yml", "data.yml", "players");Parameters:
| Parameter | Description |
|---|---|
plugin |
owning plugin |
resourcePath |
path to the bundled resource (relative to resources/) |
serverPath |
on-disk file name in the plugin data folder |
ignoredSections |
YAML top-level sections skipped during sync (e.g. player data sections) |
Accessing values
Section titled βAccessing valuesβConfig extends YamlConfiguration so all standard getters work:
String prefix = config.getString("prefix", "<gray>[Core]</gray> ");boolean debug = config.getBoolean("debug", false);int amount = config.getInt("economy.starting-balance", 100);List<String> list = config.getStringList("blocked-worlds");Saving changes
Section titled βSaving changesβconfig.set("economy.starting-balance", 500);config.save();The default config.yml
Section titled βThe default config.ymlβ# Prefix injected wherever <prefix> appears in messages.ymlprefix: "<gray>[<aqua>Core</aqua>]</gray> "
# Enables verbose debug logging to the consoledebug: falseConfigManager
Section titled βConfigManagerβUse ConfigManager (a Service) to manage multiple configs centrally and reload them all at once:
ConfigManager configs = service(ConfigManager.class);
// Load a raw configConfig data = configs.load("data.yml");
// Register a typed wrapper (see Typed Config)SettingsConfig settings = configs.register(new SettingsConfig(plugin));After registering, a single call to configs.reload() reloads every raw config and typed wrapper.