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!";
}
First of all, we need to create our configuration class. This class must be inherited from ru.xezard.configurations.Configuration. In the superclass constructor, you need to pass the full path to file with name for the configuration. Inside a class, all declared fields annotated with @ConfigurationField are considered configuration fields. The @ConfigurationField annotation value is the path for the field value in the configuration.
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;
}
}
You are done :cool:
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
Example how i use it

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!
Similar projects
Config →Let Me Despawn
Improves performance by tweaking mob despawn rules. Say bye to pesky unintentional persistent mobs.
25MSueta
JourneyMap
Real-time map used for mapping in-game or your browser as you explore.
14.7MSueta
Emotecraft
Create your own emotes in Minecraft.
7.5MSueta
Simple Tpa
A simple tpa plugin which sends requests
5.4MSueta
Common Network
Forge and Fabric Unified Networking Solution
3.9MSueta
Set Home
A lightweight plugin for players to set their homes.
3.8MSueta