Skip to content

Use score for updating text insted of teams#88

Open
Dominilk01 wants to merge 11 commits into
MrMicky-FR:masterfrom
Dominilk01:ussage-of-score-as-update
Open

Use score for updating text insted of teams#88
Dominilk01 wants to merge 11 commits into
MrMicky-FR:masterfrom
Dominilk01:ussage-of-score-as-update

Conversation

@Dominilk01

@Dominilk01 Dominilk01 commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

testes on paper 1.20.2 and paper 1.20.4 and canvas 26.1.2

with this merge can close #86

@MrMicky-FR MrMicky-FR added the enhancement New feature or request label Jun 28, 2026
Removed unnecessary code
Removed unnecessary code
Simplify ternary
- Scoreboard changes were introduced in 1.20.3, which was immediately replaced by 1.20.4
- Better naming before making VersionType public

@syldium syldium left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tested it, and the code looks good. As a side note, it would be nice if FastBoard would avoid even accessing the NMS team classes. As of now, if its signature changes, this will break the whole static initializer despite not using the classes.

Comment on lines 471 to 476

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will send a score packet twice if both the line and the score have changed.

Comment on lines +133 to +137
if (VersionType.V1_20_3.isCurrentAtLeast()) {
sendScorePacket(score, ScoreboardAction.CHANGE);
} else {
sendTeamPacket(score, TeamMode.UPDATE, prefix, suffix);
}

@syldium syldium Jun 30, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This merits a dedicated method to avoid duplicating it. For instance, a lineChanged method could take care of grouping the line and the score in the same packet if 1.20.3+ and send split packets if not:

protected void lineChanged(int line) throws Throwable {
    if (VersionType.V1_20_3.isCurrentAtLeast()) {
        sendModernScorePacket(line, ScoreboardAction.CHANGE);
    } else {
        sendTeamPacket(line, TeamMode.UPDATE, null, null);
        sendScorePacket(line, ScoreboardAction.CHANGE);
    }
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think #sendLineChange is the right place for this seperation
and its not writen in String version but Component has explain :

    /**
     * Sends a line update packet for the specified internal score.
     *
     * @param score the internal score of the line to update
     */
    @Override
    protected void sendLineChange(int score) throws Throwable {

and
you pointed in a place where #sendTeamPacket use prefix and suffix

@syldium syldium Jun 30, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, splitting the line into a prefix and a suffix has to be done somewhere. I've placed the comment here mainly because this condition that gates a sendTeamPacket call is repeated four times, but it does not seem easily avoidable, so it's fine.

@syldium syldium left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested with Spigot 1.8, Spigot 1.14, Paper 1.20.2, and Paper 26.2. It only breaks with Minecraft 26.2 :p

Comment thread src/main/java/fr/mrmicky/fastboard/FastBoardBase.java Outdated
Comment thread src/main/java/fr/mrmicky/fastboard/FastBoardBase.java Outdated
@Dueris

Dueris commented Jul 2, 2026

Copy link
Copy Markdown

Can this be tested against Canvas 26.2 aswell out of curiosity?

If not, that's fine, I just noticed Canvas was tested with this PR so I was wanting to know if that could be tested too

@byPixelTV

Copy link
Copy Markdown

Can this be tested against Canvas 26.2 aswell out of curiosity?

If not, that's fine, I just noticed Canvas was tested with this PR so I was wanting to know if that could be tested too

Tested on latest Canvas everything works fine. I had to manually apply the changes suggested by @syldium to make it work, but this is not a Canvas issue.

Comment thread src/main/java/fr/mrmicky/fastboard/FastBoardBase.java Outdated

@syldium syldium left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested with Spigot 1.8.3, Spigot 1.14.4, Paper 1.20.1, Paper 1.21.11 and Paper 2.26.2. The code looks good to me; I just left a minor style suggestion.

Comment thread src/main/java/fr/mrmicky/fastboard/FastBoardBase.java Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants