Getting Started

It's really simple!

Annotate your config class

Yes, that's the only thing you have to do.

import com.github.secretx33.sccfg.api.annotation.Configuration;

// you just have to annotate the class
@Configuration
public class MyConfig {
    
    public int someValue = 0;
    private final String someString = "rock";
}

Which is serialized to MyConfig.yml, automagically.

someValue: 0
someString: rock

Get the instance of the config class

Get the singleton instance of your config class (it'll be instantiated if required).

Use our Config class static methods.

import com.github.secretx33.sccfg.Config;

public class MyPlugin extends JavaPlugin {
    @Override
    public void onEnable() {
        // get the instance of your config
        MyConfig config = Config.getConfig(MyConfig.class);
    }
}

Note that MissingNoArgsConstructorException will be thrown if your class doesn't have a no-args constructor.

Register an instance of the config class

Sometimes, it's not possible to have a no-args constructor on our configs, if that's your case, don't you worry, we got you covered, just instantiate it yourself and register it later.

import com.github.secretx33.sccfg.Config;

public class MyPlugin extends JavaPlugin {
    @Override
    public void onEnable() {
        MyConfigOne config = new MyConfig(this); // config that require some dependency injected
        Config.registerConfig(config); // you can register any config whenever is convenient
        // Config.registerConfigs(...); // and even multiple configs at once
    }
}

Last updated