Rollback removal usage of teams prefix to handle colored scoreboard sidebar (was not working on Bedrock clients and on some Java clients)
This commit is contained in:
parent
649e1a56c8
commit
d7705d8904
@ -9,6 +9,7 @@ import org.bukkit.scoreboard.DisplaySlot;
|
|||||||
import org.bukkit.scoreboard.Objective;
|
import org.bukkit.scoreboard.Objective;
|
||||||
import org.bukkit.scoreboard.Score;
|
import org.bukkit.scoreboard.Score;
|
||||||
import org.bukkit.scoreboard.Scoreboard;
|
import org.bukkit.scoreboard.Scoreboard;
|
||||||
|
import org.bukkit.scoreboard.Team;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -63,9 +64,22 @@ public class ScoreboardUtil {
|
|||||||
*/
|
*/
|
||||||
int score = 1, i = 0;
|
int score = 1, i = 0;
|
||||||
for (int lineIndex = Math.min(lines.length, 15) - 1; lineIndex >= 0; i++, score++, lineIndex--) {
|
for (int lineIndex = Math.min(lines.length, 15) - 1; lineIndex >= 0; i++, score++, lineIndex--) {
|
||||||
|
String teamId = "sidebar_team" + score;
|
||||||
String sbEntry = colors[i].toString();
|
String sbEntry = colors[i].toString();
|
||||||
|
Team tLine = scBrd.getTeam(teamId);
|
||||||
|
if (tLine == null) {
|
||||||
|
tLine = scBrd.registerNewTeam(teamId);
|
||||||
|
}
|
||||||
|
if (!tLine.hasEntry(sbEntry)) {
|
||||||
|
tLine.addEntry(sbEntry);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!tLine.prefix().equals(lines[lineIndex])) {
|
||||||
|
tLine.prefix(lines[lineIndex]);
|
||||||
|
}
|
||||||
|
|
||||||
Score scoreEntry = obj.getScore(sbEntry);
|
Score scoreEntry = obj.getScore(sbEntry);
|
||||||
scoreEntry.customName(lines[lineIndex]);
|
// scoreEntry.customName(lines[lineIndex]); // not for now x)
|
||||||
if (scoreEntry.getScore() != score) {
|
if (scoreEntry.getScore() != score) {
|
||||||
scoreEntry.setScore(score);
|
scoreEntry.setScore(score);
|
||||||
}
|
}
|
||||||
@ -73,11 +87,17 @@ public class ScoreboardUtil {
|
|||||||
|
|
||||||
// clean older data when we are reducing the number of line displayed
|
// clean older data when we are reducing the number of line displayed
|
||||||
for (; i < colors.length; i++, score++) {
|
for (; i < colors.length; i++, score++) {
|
||||||
|
String teamId = "sidebar_team" + score;
|
||||||
String sbEntry = colors[i].toString();
|
String sbEntry = colors[i].toString();
|
||||||
|
|
||||||
if (obj.getScore(sbEntry).isScoreSet()) {
|
if (obj.getScore(sbEntry).isScoreSet()) {
|
||||||
scBrd.resetScores(sbEntry);
|
scBrd.resetScores(sbEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Team tLine = scBrd.getTeam(teamId);
|
||||||
|
if (tLine != null && !tLine.prefix().equals(Component.empty())) {
|
||||||
|
tLine.prefix(Component.empty());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user