Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty string is added each time the configuration is loaded. #30

Closed
Brikster opened this issue Jul 31, 2022 · 4 comments
Closed

Empty string is added each time the configuration is loaded. #30

Brikster opened this issue Jul 31, 2022 · 4 comments
Labels
wontfix This will not be worked on

Comments

@Brikster
Copy link

Brikster commented Jul 31, 2022

Describe the bug
New lines adds every time config loaded.

To Reproduce

TestConfig testConfig = ConfigManager.create(TestConfig.class, (it) -> {
            it.withConfigurer(new YamlBukkitConfigurer(SectionSeparator.NEW_LINE), new SerdesBukkit());
            it.withBindFile(getDataFolder().toPath().resolve("settings.yml"));
            it.withRemoveOrphans(true);
            it.saveDefaults();
            it.load(true);
        });

Each loading config will add extra empty line after header.

Expected behavior
Line shouldn't be added if already exists.

Library version

    implementation 'eu.okaeri:okaeri-configs-yaml-bukkit:4.0.6'
    implementation 'eu.okaeri:okaeri-configs-serdes-commons:4.0.6'
    implementation 'eu.okaeri:okaeri-configs-serdes-bukkit:4.0.6'
@CDFN
Copy link

CDFN commented Jul 31, 2022

Can you try without using SectionSeparator setting and see if it helps?

@Brikster
Copy link
Author

Yes, it helps, but I want to use section separator. It doesn't look like a normal behavior.

@dasavick
Copy link
Member

dasavick commented Jul 31, 2022

I don't think SectionSeparator is actually used, probably should have been removed before 4.x release. It was intended to separate root elements, not the header only. This is probably broken since the early beginnings of the library, as this is when ConfigPostprocessor was introduced to add comments in bukkit backend manually.

You may want to look into using empty @Header/@Comment annotation if you really must have the sections separated. Empty value will result with no comment prefix being placed in the line. Header at the moment requires explicit empty string due to no default value.

@Header("welcome")
@Header("welcome")
public class TestConfig extends OkaeriConfig {

    @Comment
    @Comment("hi")
    private String val1 = "a";

    // alternative
    @Comment({"", "hello"})
    private String val2 = "b";
}
# welcome
# welcome

# hi
val1: a

# hello
val: b

@dasavick dasavick added the wontfix This will not be worked on label Jul 31, 2022
@dasavick
Copy link
Member

SectionSeparator is no more (e89a574). Further discussion via #31.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants