Configuration API
The Config API provides a fluent, strongly-typed wrapper around Bukkit's standard YamlConfiguration. It simplifies file management, supports custom multi-line comments on any path, natively integrates with the Codec system to automatically serialize complex Java objects, and includes built-in schema migration support.
Creating a Configuration File
To create or load a configuration file, instantiate the Config class. The file will be automatically generated inside your plugin's plugins/<plugin_name>/ directory.
Defining Configuration Values
Instead of repeatedly typing out string paths across your codebase, the API uses a Value<T> wrapper. This allows you to define your configuration keys, their default values, and their comments in one centralized location.
If a path does not exist when value() is called, the default value is automatically written to memory.
Migrating Configurations (Schemas)
As your plugin updates, your configuration files will need to change. The Config API natively integrates with the DataFixer system, allowing you to seamlessly upgrade old YAML files without resetting user data.
Use .schema(targetVersion) to start a MigrationChain, apply your DataFixer steps, and call .apply(). Do this before calling .save() in your load sequence.
Note: This will automatically add a config_version integer to the root of your YAML file to track the current state.
Reading and Writing Data
Once your Value<T> fields are defined, you can easily read or update them from anywhere in your code. If your value uses a Codec, the API handles the decoding and encoding automatically behind the scenes.
Method Reference
Config Methods
Method | Description |
|---|---|
| Defines a standard configuration value (e.g., String, Int, Boolean, Double). |
| Defines a complex configuration value that requires encoding/decoding. |
| Initiates a migration chain to upgrade legacy configuration layouts. |
| Associates multi-line comments with a specific YAML path. |
| Writes the current configuration state to disk and safely injects custom comments. |
| Reloads the configuration data directly from the physical file. |
MigrationChain Methods
Method | Description |
|---|---|
| Registers a |
| Evaluates the current |
Value Methods
Method | Description |
|---|---|
| Retrieves the strongly-typed value. Throws a |
| Updates the value in memory. Will encode the object if a codec was provided. |
| A chainable method that adds comments above this specific value's path in the file. |