Simplix-Softworks / SimplixStorage

Library to store data in a better way
Apache License 2.0
138 stars 25 forks source link

The Yaml configs have new lines after each key #31

Closed leonardo-dgs closed 4 years ago

leonardo-dgs commented 4 years ago

Describe the bug LightningStorage generates a new line character after each Yaml config key and even a space after a section key, it's annoying. If it is expected, in the API should be added the mentioned styling options.

Code

        Yaml yamlConfig = LightningBuilder
                .fromPath("test.yml", getDataFolder().getPath())
                .setDataType(DataType.SORTED)
                .setConfigSettings(ConfigSettings.PRESERVE_COMMENTS)
                .setReloadSettings(ReloadSettings.MANUALLY)
                .createConfig();

        yamlConfig.addHeader("asdasd", "abbbb");
        yamlConfig.setPathPrefix("taaaa");
        yamlConfig.setDefault("b", "asdsadads");
        yamlConfig.setDefault("a", 32);
        yamlConfig.setDefault("c.a", "tetetetesst");

Config output

taaaa: 

   a: 32

   b: asdsadads

   c: 

      a: tetetetesst

Expected behavior I expected that Yaml configs would be generated like in the screenshots in the SpigotMC plugin page.

leonardo-dgs commented 4 years ago

The empty lines bug happens only when the option ConfigSettings is set to PRESERVE_COMMENTS

KotlinFactory commented 4 years ago

Yeah, this is known and it only happens with no comments at all. I can have a look at it.

leonardo-dgs commented 4 years ago

@JavaFactoryDev this happens even if there are comments, and after each comment are inserted several empty lines.

KotlinFactory commented 4 years ago

Should be fixed with the latest release.

KotlinFactory commented 4 years ago

Please tell me whether is still occurs or not.

leonardo-dgs commented 4 years ago

@JavaFactoryDev now this bug no longer occurs, but Yaml#addHeaders and Yaml#setHeaders works only if there is at least one empty line or comment at the beginning of the file.

KotlinFactory commented 4 years ago

Thanks for reporting it! This is indeed intended as we can't distinguish between both if there are no empty lines.