Configuration
Modifying/retrieving values from the configuration file (config.yml).
File-related methods
init()
- Creates the configuration file if it doesn't exist and then saves the configuration file.reload()
- Reloads (reads) the configuration from the file.save()
- Saves (writes) the current configuration to the file.
Retrieving values
Types
boolean
double
float
int
ItemBuilder
ItemStack
List<...> (ConfigList)
Location
Material
Text
UUID
Object
T (if you provide Class<T>)
Anyways let's retrieve a join message.
Modifying values
Updating/Setting
There are 3 methods all named set()
. The one without any parameters will lead you to a builder, and the rest are just shorter methods to do the same thing as the builder.
Types
Object
Text
Location
ItemStack
ItemBuilder
List<?>
int
double
long
float
boolean
Default value will make it so what you set is going to be the default for the config if the value ever disappears, instead of returning null.
We'll use the builder for this.
Deletion
Config
has 2 methods.
delete(ConfigKey)
delete(ConfigSection)
I don't think I need to document those self explanatory methods.
Sections
A ConfigSection
is a key which holds keys inside of it.
In our case, in join.join_message
the join
key is a configuration section.
So we can retrieve a configuration section by doing:
Retrieving Values
If we want to retrieve the join_message
key from the join
configuration section:
Modifying Values
Updating/Setting
Use section.set()
Same as setting a normal key to a value. It will return a ConfigSectionSetter.
Deletion
Use section.delete()
This will delete both the section and also the keys inside of it.
Selection
This accepts a ConfigSection
. It lets you iterate over it easily (using a forEach()
method)
Last updated
Was this helpful?