Skip to content
ZERNYTH.

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

LimitValue
File size1 MiB
Value nodes per copy100000
Entries per container10000
Nesting depth50 levels
String length1048576 UTF-16 code units
Path length4096 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.

Was this page helpful?