From 09cc894c7728d473313145a9d6bdb6ded0a8aa25 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Tue, 13 Jan 2015 14:03:40 +1300 Subject: [PATCH] Fix scoreboard --- .../arcade/scoreboard/GameScoreboard.java | 62 ++++++++----------- 1 file changed, 27 insertions(+), 35 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/GameScoreboard.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/GameScoreboard.java index ba185561d..82163f82e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/GameScoreboard.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/GameScoreboard.java @@ -1,8 +1,6 @@ package nautilus.game.arcade.scoreboard; import java.util.ArrayList; -import java.util.Objects; - import mineplex.core.common.util.C; import mineplex.core.common.util.UtilMath; import nautilus.game.arcade.game.Game; @@ -127,18 +125,18 @@ public class GameScoreboard //Base Groups for (Rank rank : Rank.values()) { - //_scoreboard.registerNewTeam(ParseTeamName(rank.Name + "SPEC")).setPrefix(ChatColor.GRAY + ""); + //_scoreboard.registerNewTeam(ParseTeamName(rank.Name + "SPEC")).setPrefix(ChatColor.GRAY + ""); } //Team Groups for (GameTeam team : Game.GetTeamList()) { - System.out.println("Scoreboard Team: " + team.GetName().toUpperCase()); - - for (Rank rank : Rank.values()) - { - _scoreboard.registerNewTeam(ParseTeamName(rank.Name + team.GetName().toUpperCase())).setPrefix(team.GetColor() + ""); - } + System.out.println("Scoreboard Team: " + team.GetName().toUpperCase()); + + for (Rank rank : Rank.values()) + { + _scoreboard.registerNewTeam(ParseTeamName(rank.Name + team.GetName().toUpperCase())).setPrefix(team.GetColor() + ""); + } } */ } @@ -172,38 +170,22 @@ public class GameScoreboard /* public void Reset() { - for (ScoreboardElement elem : _elements) - { - for (String line : elem.GetLines()) - { - ResetScore(line); - } - } + for (ScoreboardElement elem : _elements) + { + for (String line : elem.GetLines()) + { + ResetScore(line); + } + } - _elements.clear(); + _elements.clear(); - _space = " "; + _space = " "; } */ public String Clean(String line) { - if (line.length() > 28) - { - // Due to the scoreboard using teams, You can use prefix and suffix for a total length of 32. - // this means that the total length of the string can't extend 32. - // Reason for the fancy logic is that the beginning of the suffix needs to use colors from line1 else the line is pure - // white. And line2 can't have its length extend 16.. - String line1 = line.substring(0, 16); - String color = ChatColor.getLastColors(line1); - String line2 = line.substring(16); - int length = 16 - (color + line2).length(); - if (length > 0) - { - return line1 + line2.substring(0, line2.length() - length); - } - } - return line; } @@ -295,13 +277,23 @@ public class GameScoreboard String line = newLines.get(i); String prefix = line.substring(0, Math.min(line.length(), 16)); - String suffix = ChatColor.getLastColors(line) + line.substring(Math.min(team.getPrefix().length(), 16)); if (!(team.getPrefix() == null ? "" : team.getPrefix()).equals(prefix)) + { team.setPrefix(prefix); + } + + String suffix = ChatColor.getLastColors(prefix) + line.substring(prefix.length()); + + if (suffix.length() > 16) + { + suffix = suffix.substring(0, Math.min(suffix.length(), 16)); + } if (!(team.getSuffix() == null ? "" : team.getSuffix()).equals(suffix)) + { team.setSuffix(suffix); + } if (!score.isScoreSet()) {