Trim scoreboard rows

This commit is contained in:
Fabrizio La Rosa 2020-08-03 18:59:23 +02:00
parent bb37b142c8
commit 621c542d77
2 changed files with 8 additions and 2 deletions

View File

@ -113,6 +113,6 @@ class Board {
prefixLine = ChatColor.translateAlternateColorCodes(ChatColor.COLOR_CHAR, prefixLine);
suffixLine = ChatColor.translateAlternateColorCodes(ChatColor.COLOR_CHAR, lastColorCodes + suffixLine);
}
return new ScoreboardLine(prefixLine, suffixLine);
return new ScoreboardLine(prefixLine, suffixLine, allowed_line_size);
}
}

View File

@ -5,7 +5,13 @@ class ScoreboardLine {
private final String prefix;
private final String suffix;
public ScoreboardLine(String prefix, String suffix) {
public ScoreboardLine(String prefix, String suffix, int limit) {
if(prefix.length() > limit) {
prefix = prefix.substring(0, limit);
}
if(suffix.length() > limit) {
suffix = suffix.substring(0, limit);
}
this.prefix = prefix;
this.suffix = suffix;
}