Skip to content

Clear scoreboard team entries on unregister - #14159

Open
Foorcee wants to merge 1 commit into
PaperMC:mainfrom
Foorcee:bugfix/clear-team-entries-on-unregister
Open

Clear scoreboard team entries on unregister#14159
Foorcee wants to merge 1 commit into
PaperMC:mainfrom
Foorcee:bugfix/clear-team-entries-on-unregister

Conversation

@Foorcee

@Foorcee Foorcee commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Description

Unregistering a scoreboard team removes its entries from the scoreboard's internal mappings, but the entries remain stored in the old team instance.

This leaves the unregistered team in an inconsistent state. Calling hasEntry on that instance can still return true, even though the entry is no longer assigned to that team in the scoreboard.

For example:

Team t1 = scoreboard.registerNewTeam("RED");
t1.addEntry("Notch");

t1.unregister();

Team t2 = scoreboard.registerNewTeam("RED");

if (t1.hasEntry("Notch")) { // <- true
    t1.removeEntry("Notch");
}

The call to removeEntry fails with:

java.lang.IllegalStateException: Player is either on another team or not on any team. Cannot remove from team 'RED'.

This happens because t1 still contains "Notch" in its internal player list, while the scoreboard no longer considers the player to be part of that team.

Changes

Clear the team's player collection when the team is unregistered.

This ensures that an unregistered team instance accurately reflects its state and prevents stale entries from causing IllegalStateExceptions when the instance is referenced afterwards.

@Foorcee
Foorcee requested a review from a team as a code owner August 8, 2026 13:24
@github-project-automation github-project-automation Bot moved this to Awaiting review in Paper PR Queue Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Awaiting review

Development

Successfully merging this pull request may close these issues.

1 participant