mirror of
https://e.coding.net/circlecloud/MiaoBoard.git
synced 2024-11-22 01:49:05 +00:00
fix: 修复字符计算错误
Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
parent
181829f480
commit
2a05ee1b41
@ -15,7 +15,6 @@ import org.bukkit.entity.Player;
|
|||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
import pw.yumc.YumCore.bukkit.P;
|
import pw.yumc.YumCore.bukkit.P;
|
||||||
import pw.yumc.YumCore.bukkit.compatible.C;
|
import pw.yumc.YumCore.bukkit.compatible.C;
|
||||||
import pw.yumc.YumCore.kit.StrKit;
|
|
||||||
|
|
||||||
public class Replace {
|
public class Replace {
|
||||||
public static List<String> $(final Player p, final List<String> text) {
|
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) {
|
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) {
|
private static String p(final Player p, final String text) {
|
||||||
return PlaceholderAPI.setPlaceholders(p, SimpleRelpace.$(p, text));
|
return PlaceholderAPI.setPlaceholders(p, SimpleRelpace.$(p, text));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String s(final String text) {
|
|
||||||
return StrKit.substring(text, 0, 36);
|
|
||||||
}
|
|
||||||
|
|
||||||
static class SimpleRelpace {
|
static class SimpleRelpace {
|
||||||
private static final Pattern PLACEHOLDER_PATTERN = Pattern.compile("[%]([^%]+)[%]");
|
private static final Pattern PLACEHOLDER_PATTERN = Pattern.compile("[%]([^%]+)[%]");
|
||||||
private static final SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
private static final SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
@ -10,6 +10,8 @@ import org.bukkit.scoreboard.DisplaySlot;
|
|||||||
import org.bukkit.scoreboard.Objective;
|
import org.bukkit.scoreboard.Objective;
|
||||||
import org.bukkit.scoreboard.Team;
|
import org.bukkit.scoreboard.Team;
|
||||||
|
|
||||||
|
import pw.yumc.YumCore.kit.StrKit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @since 2016年7月4日 下午4:40:21
|
* @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 + "."); //确认是否存在
|
Validate.notNull(boardLine, "Unable to find BoardLine with index of " + line + "."); //确认是否存在
|
||||||
objective.getScore(boardLine.getColor().toString()).setScore(line); //设置"行"
|
objective.getScore(boardLine.getColor().toString()).setScore(line); //设置"行"
|
||||||
//分割字符串为前16个和后16个
|
//分割字符串为前16个和后16个
|
||||||
String prefix = value.substring(0, 16);
|
boardLine.getTeam().setPrefix(StrKit.substring(value, 0, 16)); //设置前16个字符
|
||||||
boardLine.getTeam().setPrefix(prefix); //设置前16个字符
|
|
||||||
if (value.length() > 16) {
|
if (value.length() > 16) {
|
||||||
String suffix = value.substring(16, value.length());
|
String suffix = value.substring(16, value.length());
|
||||||
//处理前后的颜色
|
//处理前后的颜色
|
||||||
String sufpre = "";
|
String sufpre = "";
|
||||||
String prepre = ChatColor.getLastColors(prefix);
|
String prepre = ChatColor.getLastColors(value);
|
||||||
if (prefix.charAt(15) == '§') {
|
if (value.charAt(15) == '§') {
|
||||||
sufpre = "§";
|
sufpre = "§";
|
||||||
} else if (!"".equals(prepre)) {
|
} else if (!"".equals(prepre)) {
|
||||||
sufpre = prepre;
|
sufpre = prepre;
|
||||||
}
|
}
|
||||||
suffix = (sufpre + suffix).substring(0, 16);
|
suffix = StrKit.substring(sufpre + suffix, 0, 16);
|
||||||
boardLine.getTeam().setSuffix(suffix);//"设置后16个字符"
|
boardLine.getTeam().setSuffix(suffix);//"设置后16个字符"
|
||||||
}
|
}
|
||||||
maxLine = line + 1;
|
maxLine = line + 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user