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

Emptying BossBar flags always calls bossBarFlagsChanged, even if nothing was changed #1056

Closed
threefusii opened this issue Mar 20, 2024 · 0 comments · Fixed by #1067
Closed

Comments

@threefusii
Copy link

BossBar implementations calls BossBar.Listener.bossBarFlagsChanged(...) if BossBar.flags(...) accepted an empty set, even if the flags were already empty. The following program:

// Create an example HelloWorld-alike problem.
// Can be done without any underlying platform.
BossBar bar = BossBar.bossBar(Component.text("test"), 0.0F, BossBar.Color.WHITE, BossBar.Overlay.PROGRESS, Set.of());
bar.addListener(new BossBar.Listener() {
    @Override
    public void bossBarFlagsChanged(@NotNull BossBar bar, @NotNull Set<BossBar.Flag> flagsAdded, @NotNull Set<BossBar.Flag> flagsRemoved) {
        System.out.println("Changed from " + flagsAdded + " to " + flagsRemoved);
    }
});

// Works as intended. (prints only once)
bar.flags(Set.of(BossBar.Flag.CREATE_WORLD_FOG));
bar.flags(Set.of(BossBar.Flag.CREATE_WORLD_FOG));
bar.flags(Set.of(BossBar.Flag.CREATE_WORLD_FOG));
bar.flags(Set.of(BossBar.Flag.CREATE_WORLD_FOG));
bar.flags(Set.of(BossBar.Flag.CREATE_WORLD_FOG));

// Possibly broken behavior. (prints 5 times)
bar.flags(Set.of());
bar.flags(Set.of());
bar.flags(Set.of());
bar.flags(Set.of());
bar.flags(Set.of());

prints this:

Changed from [CREATE_WORLD_FOG] to []
Changed from [] to [CREATE_WORLD_FOG]
Changed from [] to []
Changed from [] to []
Changed from [] to []
Changed from [] to []

Adventure versions: Both 4.16.0 and 4.17.0-SNAPSHOT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants