forked from circlecloud/MiaoChat
fix: 解析特殊字符错误问题
Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
parent
d4f2c62d9b
commit
29a844dd7d
5
pom.xml
5
pom.xml
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>pw.yumc</groupId>
|
||||
<artifactId>MiaoChat</artifactId>
|
||||
<version>1.8.5</version>
|
||||
<version>1.8.6</version>
|
||||
<build>
|
||||
<finalName>${project.name}</finalName>
|
||||
<resources>
|
||||
@ -70,8 +70,9 @@
|
||||
<url>http://ci.yumc.pw/job/${project.artifactId}/</url>
|
||||
</ciManagement>
|
||||
<properties>
|
||||
<update.description>§a正式版本 §bv1.8.5</update.description>
|
||||
<update.description>§a正式版本 §bv1.8.6</update.description>
|
||||
<update.changes>
|
||||
§617-08-08 §c修复: 解析特殊字符错误问题;
|
||||
§617-07-25 §c修复: 类库版本错误;
|
||||
§617-07-24 §c修复: 兼容 1.12 版本;
|
||||
§617-05-21 §c修复: BungeeCord未分配分组时报错;
|
||||
|
@ -12,9 +12,8 @@ import pw.yumc.YumCore.bukkit.P;
|
||||
import pw.yumc.YumCore.config.FileConfig;
|
||||
|
||||
/**
|
||||
*
|
||||
* @since 2016年9月9日 下午4:40:50
|
||||
* @author 喵♂呜
|
||||
* @since 2016年9月9日 下午4:40:50
|
||||
*/
|
||||
public class ChatConfig {
|
||||
private static String F = "Formats";
|
||||
|
@ -18,8 +18,8 @@ import pw.yumc.YumCore.tellraw.Tellraw;
|
||||
/**
|
||||
* 聊天规则
|
||||
*
|
||||
* @since 2016年9月9日 下午4:59:47
|
||||
* @author 喵♂呜
|
||||
* @since 2016年9月9日 下午4:59:47
|
||||
*/
|
||||
public class ChatRule extends InjectConfigurationSection {
|
||||
private transient static MiaoChat plugin = P.getPlugin();
|
||||
@ -117,7 +117,7 @@ public class ChatRule extends InjectConfigurationSection {
|
||||
}
|
||||
String tempvar = format;
|
||||
for (String var : temp) {
|
||||
String[] args = tempvar.split("\\[" + var + "]", 2);
|
||||
String[] args = tempvar.split(Pattern.quote("[" + var + "]"), 2);
|
||||
if (!"".equals(args[0])) {
|
||||
formats.add(args[0]);
|
||||
}
|
||||
|
43
src/test/pw/yumc/MiaoChat/config/ChatRuleTest.java
Normal file
43
src/test/pw/yumc/MiaoChat/config/ChatRuleTest.java
Normal file
@ -0,0 +1,43 @@
|
||||
package pw.yumc.MiaoChat.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA
|
||||
*
|
||||
* @author 喵♂呜
|
||||
* Created on 2017/8/8 16:23.
|
||||
*/
|
||||
public class ChatRuleTest {
|
||||
private transient static Pattern FORMAT_PATTERN = Pattern.compile("[\\[]([^\\[\\]]+)[]]");
|
||||
|
||||
@Test
|
||||
public void testSplit() {
|
||||
List<String> formats = new ArrayList<>();
|
||||
String format = "[mvp+][player]: ";
|
||||
Matcher m = FORMAT_PATTERN.matcher(format);
|
||||
LinkedList<String> temp = new LinkedList<>();
|
||||
while (m.find()) {
|
||||
temp.add(m.group(1));
|
||||
}
|
||||
String tempvar = format;
|
||||
for (String var : temp) {
|
||||
String[] args = tempvar.split(Pattern.quote("[" + var + "]"), 2);
|
||||
if (!"".equals(args[0])) {
|
||||
formats.add(args[0]);
|
||||
}
|
||||
formats.add(var);
|
||||
tempvar = args.length == 2 ? args[1] : "";
|
||||
}
|
||||
if (!tempvar.isEmpty()) {
|
||||
formats.add(tempvar);
|
||||
}
|
||||
formats.forEach(System.out::println);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user