Use score for updating text insted of teams#88
Conversation
Removed unnecessary code
Removed unnecessary code Simplify ternary
…ussage-of-score-as-update
- Scoreboard changes were introduced in 1.20.3, which was immediately replaced by 1.20.4 - Better naming before making VersionType public
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
This will send a score packet twice if both the line and the score have changed.
| if (VersionType.V1_20_3.isCurrentAtLeast()) { | ||
| sendScorePacket(score, ScoreboardAction.CHANGE); | ||
| } else { | ||
| sendTeamPacket(score, TeamMode.UPDATE, prefix, suffix); | ||
| } |
There was a problem hiding this comment.
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);
}
}There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
Tested with Spigot 1.8, Spigot 1.14, Paper 1.20.2, and Paper 26.2. It only breaks with Minecraft 26.2 :p
|
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. |
syldium
left a comment
There was a problem hiding this comment.
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.
testes on paper 1.20.2 and paper 1.20.4 and canvas 26.1.2
with this merge can close #86