Tentative beginnings of wider scoreboards

This commit is contained in:
libraryaddict 2015-11-05 00:42:45 +13:00
parent a0676b7bcf
commit 0352e52a68

View File

@ -1,6 +1,7 @@
package nautilus.game.arcade.scoreboard; package nautilus.game.arcade.scoreboard;
import java.util.ArrayList; import java.util.ArrayList;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import nautilus.game.arcade.game.Game; 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) public void Write(String line)
{ {
line = Clean(line);
_elements.add(new ScoreboardElementText(line)); _elements.add(new ScoreboardElementText(line));
} }
@ -213,8 +204,6 @@ public class GameScoreboard
if (prependScore) if (prependScore)
line = value + " " + line; line = value + " " + line;
line = Clean(line);
for (ScoreboardElement elem : _elements) for (ScoreboardElement elem : _elements)
{ {
if (elem instanceof ScoreboardElementScores) if (elem instanceof ScoreboardElementScores)
@ -281,9 +270,10 @@ public class GameScoreboard
team.addEntry(str); 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()) 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() public void Reset()
{ {
_elements.clear(); _elements.clear();