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:
Code (Java):
In the main class of the plugin:
Code (Java):
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 ;
}
}
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:
Code (Java):
@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!" ;
}
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!" ;
}
Code (YAML):
# First comment line
# Second comment line
Hello-world:
With-comment-above : Hello, world!
# Second comment line
Hello-world:
With-comment-above : Hello, world!
Spoiler: Example how i use it
For any errors or suggestions, write to the discussion section.Click to expand...
Quick facts
- Edition: Minecraft Java
- File type: .jar
- Minecraft versions listed: 1.7, 1.8, 1.9
- How to install: Install the matching mod loader (Forge, Fabric or NeoForge) for your Minecraft version. → Download the .jar. → Put it in the .minecraft/mods folder and launch that loader profile.
- Where to get it: Opens on Spigot — not every file is mirrored on our own servers.
Install steps are the general flow for this file type — How to install Minecraft Java mods & modpacks walks through it step by step.
XConfiguration is a free Minecraft Java mod. Compatible with Minecraft 1.7, 1.8, 1.9, 1.10 and newer. Downloaded 426 times (via Spigot). Download it and open it directly in the game.