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.
BossBar implementations calls
BossBar.Listener.bossBarFlagsChanged(...)
ifBossBar.flags(...)
accepted an empty set, even if the flags were already empty. The following program:prints this:
Adventure versions: Both 4.16.0 and 4.17.0-SNAPSHOT.