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

BossBar#viewers always return an empty list #1002

Open
2 tasks done
GoodestEnglish opened this issue Apr 26, 2024 · 1 comment
Open
2 tasks done

BossBar#viewers always return an empty list #1002

GoodestEnglish opened this issue Apr 26, 2024 · 1 comment

Comments

@GoodestEnglish
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Are you using the latest version of MockBukkit?

  • I am using the latest version of MockBukkit.

Minecraft Version

1.20

Describe the bug

So if you try to use BossBar#viewers to loop the current viewers and remove viewers from the BossBar, it doesn't produce the excepted result.

Reproducible Test

Just try to use this code to test, and you will be able to reproduce the unexcepted result.

    @Test
    void test() {
        PlayerMock player = server.addPlayer();
        BossBar bossBar = BossBar.bossBar(Component.text("hello world"),1, BossBar.Color.RED, BossBar.Overlay.PROGRESS);

        bossBar.addViewer(player);

        assertTrue(player.getBossBars().contains(bossBar)); //Passed :D

        bossBar.viewers().forEach(viewer -> {
            if (viewer instanceof Player p) {
                bossBar.removeViewer(p);
            }
        });

        assertFalse(player.getBossBars().contains(bossBar)); //Failed :(
    }

Anything else?

No response

@GoodestEnglish GoodestEnglish changed the title Cannot remove viewer from bossbar viewers loop BossBar#viewers always return an empty list Apr 26, 2024
@Thorinwasher
Copy link
Contributor

Thorinwasher commented May 1, 2024

I can reproduce this.

We need to register a service for this to work properly

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

No branches or pull requests

2 participants