Skip to content

Commit 858b0fe

Browse files
committed
By default for lower 1.13 versions remove special chars from Scoreboard lines
1 parent 3917753 commit 858b0fe

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/arena/managers/PluginScoreboardManager.java

+19-8
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,7 @@ public void createScoreboard(IUser user) {
5858
FastBoard board = new FastBoard(player) {
5959
@Override
6060
public boolean hasLinesMaxLength() {
61-
if(Bukkit.getPluginManager().isPluginEnabled("ViaVersion")) {
62-
try {
63-
return Via.getAPI().getPlayerVersion(getPlayer()) < ProtocolVersion.v1_13.getVersion();
64-
} catch(Exception ignored) {
65-
//Not using ViaVersion 4 or unable to get ViaVersion return LegacyBoard!
66-
}
67-
}
68-
return !ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_13);
61+
return isLinesMaxLength(getPlayer());
6962
}
7063
};
7164

@@ -101,10 +94,28 @@ public List<String> getScoreboardLines(Player player) {
10194
@Override
10295
public List<String> formatScoreboardLines(List<String> lines, Player player) {
10396
List<String> formattedLines = new ArrayList<>();
97+
if(isLinesMaxLength(player)) {
98+
List<String> linesWithoutSpecialChars = new ArrayList<>();
99+
for(String line : lines) {
100+
linesWithoutSpecialChars.add(line.replace("■ ", "").replace("|", ""));
101+
}
102+
lines = linesWithoutSpecialChars;
103+
}
104104
for(String line : lines) {
105105
formattedLines.add(new MessageBuilder(line).player(player).arena(arena).build());
106106
}
107107
return formattedLines;
108108
}
109109

110+
private boolean isLinesMaxLength(Player player) {
111+
if(Bukkit.getPluginManager().isPluginEnabled("ViaVersion")) {
112+
try {
113+
return Via.getAPI().getPlayerVersion(player) < ProtocolVersion.v1_13.getVersion();
114+
} catch(Exception ignored) {
115+
//Not using ViaVersion 4 or unable to get ViaVersion return LegacyBoard!
116+
}
117+
}
118+
return !ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_13);
119+
}
120+
110121
}

0 commit comments

Comments
 (0)