1
0
mirror of https://e.coding.net/circlecloud/MiaoBoard.git synced 2025-11-03 17:56:30 +00:00

fix: 修复颜色拼接错误的问题

Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
2017-01-06 20:24:00 +08:00
parent 802433ac9e
commit 181829f480
2 changed files with 13 additions and 22 deletions

View File

@@ -3,7 +3,6 @@ package pw.yumc.MiaoBoard.scoreboard.core;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
@@ -48,20 +47,20 @@ public class SiderbarBoardPage extends BoardPage {
final BoardLine boardLine = getBoardLine(line); //得到我们的"行"
Validate.notNull(boardLine, "Unable to find BoardLine with index of " + line + "."); //确认是否存在
objective.getScore(boardLine.getColor().toString()).setScore(line); //设置"行"
String prefix = value;
String suffix = null;
//分割字符串为前16个和后16个
if (value.length() > 16) {
prefix = value.substring(0, 16);
if (ChatColor.getLastColors(prefix) != null && !Objects.equals(ChatColor.getLastColors(prefix), "") && !Objects.equals(ChatColor.getLastColors(prefix), " ")) {
//继承前16个字符的颜色
suffix = ChatColor.getLastColors(prefix) + value.substring(16, value.length());
} else {
suffix = ChatColor.RESET + value.substring(16, value.length());
}
}
String prefix = value.substring(0, 16);
boardLine.getTeam().setPrefix(prefix); //设置前16个字符
if (suffix != null) {
if (value.length() > 16) {
String suffix = value.substring(16, value.length());
//处理前后的颜色
String sufpre = "";
String prepre = ChatColor.getLastColors(prefix);
if (prefix.charAt(15) == '§') {
sufpre = "§";
} else if (!"".equals(prepre)) {
sufpre = prepre;
}
suffix = (sufpre + suffix).substring(0, 16);
boardLine.getTeam().setSuffix(suffix);//"设置后16个字符"
}
maxLine = line + 1;