From 0352e52a688904ce20fc37e2ac60f7bc25d27d3e Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Thu, 5 Nov 2015 00:42:45 +1300 Subject: [PATCH] Tentative beginnings of wider scoreboards --- .../arcade/scoreboard/GameScoreboard.java | 50 +++++++++++++------ 1 file changed, 36 insertions(+), 14 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 3771e03e5..7dc3863e1 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,6 +1,7 @@ package nautilus.game.arcade.scoreboard; import java.util.ArrayList; + import mineplex.core.common.util.C; import mineplex.core.common.util.UtilMath; import nautilus.game.arcade.game.Game; @@ -193,18 +194,8 @@ public class GameScoreboard } */ - public String Clean(String line) - { - if (line.length() > 16) - line = line.substring(0, 16); - - return line; - } - public void Write(String line) { - line = Clean(line); - _elements.add(new ScoreboardElementText(line)); } @@ -213,8 +204,6 @@ public class GameScoreboard if (prependScore) line = value + " " + line; - line = Clean(line); - for (ScoreboardElement elem : _elements) { if (elem instanceof ScoreboardElementScores) @@ -281,9 +270,10 @@ public class GameScoreboard team.addEntry(str); } - String line = newLines.get(i); + String[] line = split(newLines.get(i)); - team.setPrefix(line); + team.setPrefix(line[0]); + team.setSuffix(line[1]); if (!score.isScoreSet()) { @@ -300,6 +290,38 @@ public class GameScoreboard } } + private String[] split(String line) + { + String[] strings = new String[2]; + + if (line.length() > 16) + { + String line1 = line.substring(0, 16); + String line2 = line.substring(16); + + if (line1.endsWith(ChatColor.COLOR_CHAR + "")) + { + line2 = line1.substring(15, 16) + line2; + line1 = line1.substring(0, 15); + } + + line2 = ChatColor.getLastColors(line1) + line2; + + if (line2.length() > 16) + { + line2 = line2.substring(0, 16); + } + + strings[0] = line1; + strings[1] = line2; + } + else + { + strings[0] = line; + } + + return strings; + } public void Reset() { _elements.clear();