XConfiguration 2.0.2

Universal library for work with yml configurations

  1. CoolBoy
    Native Minecraft Version:
    1.14
    Tested Minecraft Versions:
    • 1.7
    • 1.8
    • 1.9
    • 1.10
    • 1.11
    • 1.12
    • 1.13
    • 1.14
    • 1.15
    • 1.16
    Source Code:
    https://github.com/Xezard/XConfiguration
    Contributors:
    Xezard
    [​IMG]

    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):
    @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:
    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;
        }
    }
    You are done :cool:

    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!";
    }
    After calling the load() method, you can see the new configuration:
    Code (YAML):
    # 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

    [​IMG]
    [​IMG]

    PROgrm_JARvis and Resoluciones like this.

Recent Updates

  1. XConfiguration v.2.0.2
  2. Update 2.0.1.
  3. Major update.

Recent Reviews

  1. Stashenko
    Stashenko
    5/5,
    Version: 1.2
    Хорошие функции плагина от отличного парня. Привет от Спигот Ру. В России нет плохих разрабов!
  2. SteffenFL
    SteffenFL
    3/5,
    Version: 1.2
    *.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*..*
    nice plugin
    *.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.