importcom.github.secretx33.sccfg.api.annotation.Configuration;// you just have to annotate the class@ConfigurationpublicclassMyConfig {publicint someValue =0;privatefinalString someString ="rock";}
Which is serialized to MyConfig.yml, automagically.
someValue:0someString: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.
importcom.github.secretx33.sccfg.Config;publicclassMyPluginextendsJavaPlugin { @OverridepublicvoidonEnable() {// get the instance of your configMyConfig config =Config.getConfig(MyConfig.class); }}
Use our extension functions (or our Config class static methods, too).
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.
importcom.github.secretx33.sccfg.Config;publicclassMyPluginextendsJavaPlugin { @OverridepublicvoidonEnable() {MyConfigOne config =newMyConfig(this); // config that require some dependency injectedConfig.registerConfig(config); // you can register any config whenever is convenient// Config.registerConfigs(...); // and even multiple configs at once }}
import com.github.secretx33.sccfg.registerConfigimport com.github.secretx33.sccfg.registerConfigsclassMyPlugin : JavaPlugin() {overridefunonEnable() {val config =MyConfig(this) // config that require some dependency injectedregisterConfig(config) // you can register any config whenever is convenient// registerConfigs(...) // and even multiple configs at once }}