-
Notifications
You must be signed in to change notification settings - Fork 2
Home
This wiki is quite straight forward, just a basic explanation of how to use AnnotationConfig, and a description of each Annotation.
To create a config using the AnnotationConfig, you need to create a class extending the AnnotationConfig class, and to add an Annotation describing the config file :
@ConfigFile
public class Config extends AnnotationConfig
{
}
You can then add fields, and simply mark them as config fields:
@ConfigFile
public class Config extends AnnotationConfig
{
@ConfigField
public String someConfigField;
}
Both Attributes have optionnal parameters to make the fields more complete, they are decribed at the bottom of the page.
To load / save a config, you can simply do :
Config config = new Config();
config.loadConfig();// loads config or default (if nothing specified, this will load the "config.yml" file)
config.saveConfig();// save eventual default (if nothing specified, this will save the "config.yml" file)
config.loadConfig("otherFile.yml");// loads config or default
config.saveConfig("otherFile.yml");// save eventual default
You can re-save the config at any point
This attribute is used to mark an AnnotationConfig class. It has the following optionnal parameters:
- header: The header to add at the beginning of the file. Now supports multi-line comments
This attribute is used to mark a field as a serialized field. It has the following optionnal parameters:
- name: The path at which you want to save the field at. By default, it is the field variable name.
- comment: A comment to add before the config line. Can be used to describe the expected value.