diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/ScoreboardUtil.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/ScoreboardUtil.java index e3d663d..e80d1aa 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/ScoreboardUtil.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/ScoreboardUtil.java @@ -9,6 +9,7 @@ import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.Objective; import org.bukkit.scoreboard.Score; import org.bukkit.scoreboard.Scoreboard; +import org.bukkit.scoreboard.Team; import java.util.List; @@ -63,9 +64,22 @@ public class ScoreboardUtil { */ int score = 1, i = 0; for (int lineIndex = Math.min(lines.length, 15) - 1; lineIndex >= 0; i++, score++, lineIndex--) { + String teamId = "sidebar_team" + score; 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); - scoreEntry.customName(lines[lineIndex]); + // scoreEntry.customName(lines[lineIndex]); // not for now x) if (scoreEntry.getScore() != score) { scoreEntry.setScore(score); } @@ -73,11 +87,17 @@ public class ScoreboardUtil { // clean older data when we are reducing the number of line displayed for (; i < colors.length; i++, score++) { + String teamId = "sidebar_team" + score; String sbEntry = colors[i].toString(); if (obj.getScore(sbEntry).isScoreSet()) { scBrd.resetScores(sbEntry); } + + Team tLine = scBrd.getTeam(teamId); + if (tLine != null && !tLine.prefix().equals(Component.empty())) { + tLine.prefix(Component.empty()); + } } }