Skip to content

Creating a simple config

Ang edited this page Nov 18, 2022 · 1 revision

Config Options

Paragon uses ConfigOption to save config data, and information. Below is an example of a ConfigOption.

public static final ConfigOption<String> DISCORD_USERNAME = new ConfigOption<>("username", new String("acee#1220"));

Config Class

Currently, this won't do anything by itself. You will need a config class to store your config options. Let's make one! I'll name my class TestModConfig. This code currently uses version 2.1.0, but 3.0.0 will be releasing soon which will rewrite most of Paragon's internal systems, and overall experience.

import com.kyanite.paragon.api.ConfigGroup;
import com.kyanite.paragon.api.ConfigOption;
import com.kyanite.paragon.api.interfaces.configtypes.JSONModConfig;

public class TestModConfig implements JSONModConfig {
    public static final ConfigOption<String> DISCORD_USERNAME = new ConfigOption<>("username", new String("acee#1220"));

    @Override
    public String getModId() {
        return "paragon";
    }
}

Config Registration

If you try this, it will do absolutely nothing. This is because you haven't registered your config class yet! Here's how to do it:

ConfigRegistry.register(new TestModConfig());

This should be in your main class, or some sort of initializer. It should not be in your config class.

Paragon is a simple, easy-to-use and lightweight config library.

Clone this wiki locally