+ * Without overriding, players below 1.20.3 will not see text lines on servers running 1.20.3+.
+ *
+ * @return {@code true} to use score text, {@code false} for legacy teams
+ */
+ protected boolean hasCustomScores() {
+ return true;
+ }
+
private void checkLineNumber(int line, boolean checkInRange, boolean checkMax) {
if (line < 0) {
throw new IllegalArgumentException("Line number must be positive");
@@ -666,15 +678,7 @@ protected Object sendObjectivePacket(ObjectiveMode mode) throws Throwable {
false, // Auto-update, unused
null // Number format
);
- } else if (VersionType.V1_17.isHigherOrEqual()) {
- objective = OBJECTIVE.invoke(
- null, // Scoreboard, unused
- this.id, // Objective name
- null, // Criteria, unused
- toMinecraftComponent(this.title), // Display name
- ENUM_SB_HEALTH_DISPLAY_INTEGER // Render type
- );
- } else if (VersionType.V1_13.isHigherOrEqual()) {
+ } else if (VersionType.V1_13.isCurrentAtLeast()) {
objective = OBJECTIVE.invoke(
null, // Scoreboard, unused
this.id, // Objective name
@@ -705,7 +709,7 @@ protected void sendDisplayObjectivePacket(Object objective) throws Throwable {
}
protected void sendScorePacket(int score, ScoreboardAction action) throws Throwable {
- if (VersionType.V1_17.isHigherOrEqual()) {
+ if (VersionType.V1_17.isCurrentAtLeast()) {
sendModernScorePacket(score, action);
return;
}
@@ -714,7 +718,7 @@ protected void sendScorePacket(int score, ScoreboardAction action) throws Throwa
setField(packet, String.class, COLOR_CODES[score], 0); // Player Name
- if (VersionType.V1_8.isHigherOrEqual()) {
+ if (VersionType.V1_8.isCurrentAtLeast()) {
Object enumAction = action == ScoreboardAction.REMOVE
? ENUM_SB_ACTION_REMOVE : ENUM_SB_ACTION_CHANGE;
setField(packet, ENUM_SB_ACTION, enumAction);
@@ -730,7 +734,7 @@ protected void sendScorePacket(int score, ScoreboardAction action) throws Throwa
sendPacket(packet);
}
- private void sendModernScorePacket(int score, ScoreboardAction action) throws Throwable {
+ protected void sendModernScorePacket(int score, ScoreboardAction action) throws Throwable {
String objName = COLOR_CODES[score];
Object enumAction = action == ScoreboardAction.REMOVE
? ENUM_SB_ACTION_REMOVE : ENUM_SB_ACTION_CHANGE;
@@ -745,13 +749,14 @@ private void sendModernScorePacket(int score, ScoreboardAction action) throws Th
return;
}
- T scoreFormat = getLineByScore(this.scores, score);
- Object format = scoreFormat != null
- ? FIXED_NUMBER_FORMAT.invoke(toMinecraftComponent(scoreFormat))
+ Object text = toMinecraftComponent(getLineByScore(score));
+ T rawFormat = getLineByScore(this.scores, score);
+ Object format = rawFormat != null
+ ? FIXED_NUMBER_FORMAT.invoke(toMinecraftComponent(rawFormat))
: BLANK_NUMBER_FORMAT;
Object scorePacket = SCORE_OPTIONAL_COMPONENTS
- ? PACKET_SB_SET_SCORE.invoke(objName, this.id, score, Optional.empty(), Optional.of(format))
- : PACKET_SB_SET_SCORE.invoke(objName, this.id, score, null, format);
+ ? PACKET_SB_SET_SCORE.invoke(objName, this.id, score, Optional.of(text), Optional.of(format))
+ : PACKET_SB_SET_SCORE.invoke(objName, this.id, score, text, format);
sendPacket(scorePacket);
}
@@ -768,7 +773,7 @@ protected void sendTeamPacket(int score, TeamMode mode, T prefix, T suffix)
Object packet;
if (mode == TeamMode.REMOVE) {
- if (VersionType.V1_17.isHigherOrEqual()) {
+ if (VersionType.V1_17.isCurrentAtLeast()) {
packet = PACKET_SB_TEAM.invoke(
this.id + ':' + score, // Team name
mode.ordinal(), // Update mode
@@ -784,7 +789,7 @@ protected void sendTeamPacket(int score, TeamMode mode, T prefix, T suffix)
return;
}
- if (VersionType.V1_17.isHigherOrEqual()) {
+ if (VersionType.V1_17.isCurrentAtLeast()) {
Object team = PLAYER_TEAM.invoke(null, this.id + ':' + score);
setComponentField(team, null, 1); // Display name
setComponentField(team, prefix, 2); // Prefix
@@ -840,7 +845,7 @@ private void setField(Object packet, Class> fieldType, Object value, int count
}
private void setComponentField(Object packet, T value, int count) throws Throwable {
- if (!VersionType.V1_13.isHigherOrEqual()) {
+ if (!VersionType.V1_13.isCurrentAtLeast()) {
String line = value != null ? serializeLine(value) : "";
setField(packet, String.class, line, count);
return;
@@ -866,11 +871,11 @@ public enum ScoreboardAction {
CHANGE, REMOVE
}
- enum VersionType {
- V1_7, V1_8, V1_13, V1_17;
+ public enum VersionType {
+ V1_7, V1_8, V1_13, V1_17, V1_20_3;
- public boolean isHigherOrEqual() {
+ public boolean isCurrentAtLeast() {
return VERSION_TYPE.ordinal() >= ordinal();
}
}
-}
\ No newline at end of file
+}
diff --git a/Plugin/src/main/java/fr/mrmicky/fastboard/adventure/FastBoard.java b/Plugin/src/main/java/fr/mrmicky/fastboard/adventure/FastBoard.java
index fb86f48a8..c63a5e543 100644
--- a/Plugin/src/main/java/fr/mrmicky/fastboard/adventure/FastBoard.java
+++ b/Plugin/src/main/java/fr/mrmicky/fastboard/adventure/FastBoard.java
@@ -1,7 +1,7 @@
/*
* This file is part of FastBoard, licensed under the MIT License.
*
- * Copyright (c) 2019-2023 MrMicky
+ * Copyright (c) 2019-2026 MrMicky
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -35,7 +35,7 @@
import java.lang.reflect.Method;
/**
- * {@inheritDoc}
+ * Adventure {@link Component}-based implementation of {@link FastBoardBase}.
*/
public class FastBoard extends FastBoardBase