ConfigLib icon

ConfigLib -----

A Minecraft library for saving, loading, updating, and commenting YAML configuration files



Tired of Bukkit's configuration system? Use this library instead! Just write Java code and let this library do the rest. More information on GitHub.

This library facilitates creating, saving, loading, updating, and commenting YAML configuration files. It does so by automatically mapping instances of configuration classes to serializable maps which are first transformed into YAML and then saved to some specified file.

For a step-by-step tutorial that shows most features of this library in action check out the Tutorial page on the wiki!

This library is also available as a BungeeCord (/ Waterfall) plugin.

Features
  • Automatic creation, saving, loading, and updating of configuration files
  • Support for comments through annotations
  • Support for all primitive types, their wrapper types, and strings
  • Support for enums, records, and POJOs (+ inheritance!)
  • Support for (nested) lists, sets, arrays, and maps
  • Support for BigInteger and BigDecimal
  • Support for LocalDate, LocalTime, LocalDateTime, and Instant
  • Support for UUID, File, Path, URL, and URI
  • Support for Bukkit's ConfigurationSerializable types (e.g. ItemStack)
  • Option to exclude fields from being converted
  • Option to format field and component names before conversion
  • Option to customize null handling
  • Option to customize serialization by providing your own serializers
  • Option to add headers and footers to configuration files
  • ...and a few more!

Example:

This section contains a short usage example to get you started. For a step-by-step tutorial with a more advanced example check out the Tutorial page on the wiki.

If you want support Bukkit classes like ItemStack, check out the Configuration properties section on GitHub.

Code (Java):
public final class Example {
    // * To create a configuration annotate a class with @Configuration and make sure that
    //   it has a no-args constructor.
    // * Now add fields to that class and assign them default values.
    // * That's it! Fields can be private; setters are not required.
   @Configuration
    public static class BaseConfiguration {
        private String host = "127.0.0.1" ;
        private int port = 1234 ;
        // The library supports lists, sets, and maps.
        private Set <String > blockedAddresses = Set. of ( "8.8.8.8" ) ;
        // Fields can be ignored by making them final, transient, static or by
        // annotating them with @Ignore.
        private final double ignoreMe = 3.14 ;
    }

    // This library supports records; no @Configuration annotation required
    public record User (
            String username,
           @Comment ( "Please choose a strong password." )
            String password
    ) { }

    // Subclassing of configurations and nesting of configurations in other configurations
    // is also supported. Subclasses don't need to be annotated again.
    public static final class UserConfiguration extends BaseConfiguration {
        // You can add comments with the @Comment annotation. Each string in the comment
        // array is written (as a comment) on a new line.
       @Comment ( { "The admin user has full access.", "Choose a proper password!" } )
       User admin = new User ( "root", "toor" ) ; // The User class is a record!
       List <User > blockedUsers = List. of (
                new User ( "user1", null ), // null values are supported
                new User ( "user2", null )
        ) ;
    }

    public static void main ( String [ ] args ) {
       var configFile = Paths. get ( "/tmp/config.yml" ) ;
       var config = new UserConfiguration ( ) ;

        // Save a new instance to the configuration file
       YamlConfigurations. save (configFile, UserConfiguration. class, config ) ;

        // Load a new instance from the configuration file
       config = YamlConfigurations. load (configFile, UserConfiguration. class ) ;
        System. out. println (config. admin. username ) ;
        System. out. println (config. blockedUsers ) ;

        // Modify and save the configuration file
       config. blockedUsers. add ( new User ( "user3", "pass3" ) ) ;
       YamlConfigurations. save (configFile, UserConfiguration. class, config ) ;
    }
}
Executing the code above creates the following configuration file:
Code (YAML):
host : 127.0.0.1
port
: 1234
blockedAddresses
:
 - 8.8.8.8
# The admin user has full access.
# Choose a proper password!
admin
:
  username
: root
  # Please choose a strong password.
  password
: toor
blockedUsers
:
  - username
: user1
  - username
: user2
  - username
: user3
    password
: pass3
For a detailed description of the capabilities and a documentation of this library, check out the repository on GitHub!
Resource Information
Author:
----------
Total Downloads: 1,549
First Release: Aug 9, 2018
Last Update: Apr 27, 2025
Category: ---------------
All-Time Rating:
3 ratings
Find more info at github.com...
Version -----
Released: --------------------
Downloads: ------
Version Rating:
----------------------
-- ratings