-
Notifications
You must be signed in to change notification settings - Fork 46
Configuration API
Andre_601 edited this page Jan 3, 2019
·
1 revision
The Configuration API allows you to generate a config file with all values and comments you define.
This API only allows creation and load of the file.
Configuration notes and value paths are delimited by .
-characters.
For example: Value1.Value2
becomes:
Value1:
Value2: //something here
Used to set a yaml file to the load or write the values too.
Example:
FileConfiguration config = new FileConfiguration(this, "config.yml");
Parameter: | Type: |
---|---|
JavaPlugin | Instance of your plugin |
String | Name of the file (with extension) |
Loads the FileConfiguration file, if it exists.
Sets values of the FileConfiguration file.
You have to run the #save();
after you set the values, to generate the file.
Example:
config.set("SomeKey", 1);
Parameter: | Type: |
---|---|
String | Name of the key |
Object | The value of the key |
Saves the set values from #set(String, Object);
to the actual file (Generates it).
Gets the value from the provided key, or sets the default one, if none is set (non-existant).
Run #save();
after this method, to directly save the missing keys.
Example:
config.get("SomeKey", 5);
Parameter: | Type: |
---|---|
String | Name of the key to get the value from |
Object | Default value, if key doesn't exist |