1
0
mirror of https://e.coding.net/circlecloud/MiaoBoard.git synced 2024-11-25 02:19:07 +00:00

fix: 修复字符计算错误

Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
502647092 2017-01-06 20:36:35 +08:00
parent 181829f480
commit 2a05ee1b41
2 changed files with 7 additions and 11 deletions

View File

@ -15,7 +15,6 @@ import org.bukkit.entity.Player;
import me.clip.placeholderapi.PlaceholderAPI;
import pw.yumc.YumCore.bukkit.P;
import pw.yumc.YumCore.bukkit.compatible.C;
import pw.yumc.YumCore.kit.StrKit;
public class Replace {
public static List<String> $(final Player p, final List<String> text) {
@ -27,17 +26,13 @@ public class Replace {
}
public static String $(final Player p, final String text) {
return s(p(p, text));
return p(p, text);
}
private static String p(final Player p, final String text) {
return PlaceholderAPI.setPlaceholders(p, SimpleRelpace.$(p, text));
}
private static String s(final String text) {
return StrKit.substring(text, 0, 36);
}
static class SimpleRelpace {
private static final Pattern PLACEHOLDER_PATTERN = Pattern.compile("[%]([^%]+)[%]");
private static final SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

View File

@ -10,6 +10,8 @@ import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Team;
import pw.yumc.YumCore.kit.StrKit;
/**
*
* @since 2016年7月4日 下午4:40:21
@ -48,19 +50,18 @@ public class SiderbarBoardPage extends BoardPage {
Validate.notNull(boardLine, "Unable to find BoardLine with index of " + line + "."); //确认是否存在
objective.getScore(boardLine.getColor().toString()).setScore(line); //设置""
//分割字符串为前16个和后16个
String prefix = value.substring(0, 16);
boardLine.getTeam().setPrefix(prefix); //设置前16个字符
boardLine.getTeam().setPrefix(StrKit.substring(value, 0, 16)); //设置前16个字符
if (value.length() > 16) {
String suffix = value.substring(16, value.length());
//处理前后的颜色
String sufpre = "";
String prepre = ChatColor.getLastColors(prefix);
if (prefix.charAt(15) == '§') {
String prepre = ChatColor.getLastColors(value);
if (value.charAt(15) == '§') {
sufpre = "§";
} else if (!"".equals(prepre)) {
sufpre = prepre;
}
suffix = (sufpre + suffix).substring(0, 16);
suffix = StrKit.substring(sufpre + suffix, 0, 16);
boardLine.getTeam().setSuffix(suffix);//"设置后16个字符"
}
maxLine = line + 1;