Skip to content
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-api</artifactId>
<version>5.1.1</version>
<version>5.2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-serializer-legacy</artifactId>
<version>5.1.1</version>
<version>5.2.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
16 changes: 12 additions & 4 deletions src/main/java/fr/mrmicky/fastboard/FastBoard.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public FastBoard(Player player) {
public void updateTitle(String title) {
Objects.requireNonNull(title, "title");

if (!VersionType.V1_13.isHigherOrEqual() && title.length() > 32) {
if (!VersionType.V1_13.isCurrentAtLeast() && title.length() > 32) {
throw new IllegalArgumentException("Title is longer than 32 chars");
}

Expand All @@ -82,7 +82,7 @@ public void updateTitle(String title) {
public void updateLines(String... lines) {
Objects.requireNonNull(lines, "lines");

if (!VersionType.V1_13.isHigherOrEqual()) {
if (!VersionType.V1_13.isCurrentAtLeast()) {
int lineCount = 0;
for (String s : lines) {
if (s != null && s.length() > 30) {
Expand All @@ -95,6 +95,9 @@ public void updateLines(String... lines) {
super.updateLines(lines);
}

/**
* {@inheritDoc}
*/
@Override
protected void sendLineChange(int score) throws Throwable {
int maxLength = hasLinesMaxLength() ? 16 : 1024;
Expand Down Expand Up @@ -130,7 +133,12 @@ protected void sendLineChange(int score) throws Throwable {
suffix = suffix.substring(0, Math.min(maxLength, suffix.length()));
}

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

@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.

}

@Override
Expand Down Expand Up @@ -160,6 +168,6 @@ protected String emptyLine() {
* @return true if scoreboard lines are limited by the legacy prefix/suffix length
*/
protected boolean hasLinesMaxLength() {
return !VersionType.V1_13.isHigherOrEqual();
return !VersionType.V1_13.isCurrentAtLeast();
}
}
Loading