
XConfiguration 2.0.2
Universal library for work with yml configurations

XConfiguration is a universal annotation-based library for interacting with yml configurations. With it, you can automatically create / reload your configurations, make comments in them, and most importantly, save and receive your Java objects from the configuration automatically!
Basic usage
Consider the following example:
@Getter
public class MessagesConfiguration
extends Configuration
{
public MessagesConfiguration(File folder)
{
super(folder.getAbsolutePath() + File.separator + "messages.yml");
}
@ConfigurationField("Hello-world")
public String helloWorld = "Hello, world!";
}
In the main class of the plugin:
public class Main
extends JavaPlugin
{
/*
* Creating an instance of our configuration class
*/
private MessagesConfiguration messagesConfiguration = new MessagesConfiguration(this.getDataFolder());
@Override
public void onEnable()
{
/*
* This method automatically creates a configuration file
* if it has not already been created. Also, it fills your class
* with values from the configuration, or vice versa fills the
* configuration with values from the class if there are no
* corresponding fields in the configuration.
*
* You can also call this method when you want to reload
* the configuration of your plugin.
*/
this.messagesConfiguration.load();
/*
* After loading the configuration, we can easily get
* the values of our fields from the class.
*/
this.getLogger().info(this.messagesConfiguration.getHelloWorld());
}
@Override
public void onDisable()
{
this.messagesConfiguration = null;
}
}
Comments
When you defining configuration fields, you can also add comments to them:
@Getter
public class MessagesConfiguration
extends Configuration
{
public MessagesConfiguration(File folder)
{
super(folder.getAbsolutePath() + File.separator + "messages.yml");
}
@ConfigurationField("Hello-world.With-comment-above")
@ConfigurationComments({"# First comment line", "# Second comment line"})
public String helloWorld = "Hello, world!";
}
After calling the load() method, you can see the new configuration:
# First comment line
# Second comment line
Hello-world:
With-comment-above: Hello, world!
For more features check out XConfiguration wiki page on github: https://github.com/Xezard/XConfiguration/wiki
[dropdown=Example how i use it]


[/dropdown]
For any errors or suggestions, write to the discussion section.
If you use XConfiguration and you like it, please rate and leave a review about it!
If you use XConfiguration and you like it, please rate and leave a review about it!