Configuration
Bundle a config.yml in your JAR and use the configuration methods on JavaPlugin. Files live in the plugin's data folder. All of these methods can throw IOException.
package dev.example;
import dev.zernyth.api.plugin.JavaPlugin;
import java.io.IOException;
public final class ConfigPlugin extends JavaPlugin {
@Override
public void onEnable() {
try {
saveDefaultConfig();
var config = getConfig();
String name = config.getString("server.name", "Zernyth Server");
int limit = config.getInt("limits.players", 20);
getLogger().info(name + " allows " + limit);
config.set("last.started", System.currentTimeMillis());
saveConfig();
} catch (IOException error) {
throw new IllegalStateException("Cannot load configuration", error);
}
}
}Behaviour
Reloading is explicit, and configuration is never saved automatically on disable. For additional files, use getStorage().
Limits
| Limit | Value |
|---|---|
| File size | 1 MiB |
| Value nodes per copy | 100000 |
| Entries per container | 10000 |
| Nesting depth | 50 levels |
| String length | 1048576 UTF-16 code units |
| Path length | 4096 characters, 50 segments |
YAML is read without aliases. A failed set leaves the state unchanged. Configuration changes are not meant for code that runs every tick.