Skip to content

hpfxd/configurate-eo-yaml

Repository files navigation

configurate-eo-yaml

YAML configuration loader for Configurate using eo-yaml.

Why?

Currently in Configurate, the YAML loader which is implemented using SnakeYAML does not support writing comments.

The only loaders that support round-tripping comments are Hocon and XML. I personally find XML to be a bit annoying to use for configurations (looking at you Maven...), and the Hocon loader uses a Map implementation internally that does not preserve the ordering of entries, which means when saving, the options are all over the place.

eo-yaml both properly preserves entry ordering, and supports round-tripping comments. :)

Usage

Gradle

repositories {
    mavenCentral()
}

dependencies {
    implementation("com.hpfxd.configurate:configurate-eo-yaml:1.0.0")
}

Maven

<dependencies>
    <dependency>
        <groupId>com.hpfxd.configurate</groupId>
        <artifactId>configurate-eo-yaml</artifactId>
        <version>1.0.0</version>
    </dependency>
</dependencies>

Once you have the library imported into your project, you can just use it like any other Configurate loader:

EOYamlConfigurationLoader loader = EOYamlConfigurationLoader.builder()
        .file(new File("./config.yml"))
        .build();

The loader only has one unique option: guessIndentation. See the eo-yaml wiki for more information. You can set this option by calling guessIndentation(boolean) on the builder. By default, this option is set to false.

About

YAML configuration loader for Configurate utilizing eo-yaml

Topics

Resources

License

Stars

Watchers

Forks