merge/11/MERGE
Coding 2017-08-08 22:44:45 +08:00
commit d9c770d378
5 changed files with 52 additions and 9 deletions

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>pw.yumc</groupId> <groupId>pw.yumc</groupId>
<artifactId>MiaoChat</artifactId> <artifactId>MiaoChat</artifactId>
<version>1.8.5</version> <version>1.8.6</version>
<build> <build>
<finalName>${project.name}</finalName> <finalName>${project.name}</finalName>
<resources> <resources>
@ -70,8 +70,9 @@
<url>http://ci.yumc.pw/job/${project.artifactId}/</url> <url>http://ci.yumc.pw/job/${project.artifactId}/</url>
</ciManagement> </ciManagement>
<properties> <properties>
<update.description>§a正式版本 §bv1.8.5</update.description> <update.description>§a正式版本 §bv1.8.6</update.description>
<update.changes> <update.changes>
§617-08-08 §c修复: 解析特殊字符错误问题;
§617-07-25 §c修复: 类库版本错误; §617-07-25 §c修复: 类库版本错误;
§617-07-24 §c修复: 兼容 1.12 版本; §617-07-24 §c修复: 兼容 1.12 版本;
§617-05-21 §c修复: BungeeCord未分配分组时报错; §617-05-21 §c修复: BungeeCord未分配分组时报错;

View File

@ -12,9 +12,8 @@ import pw.yumc.YumCore.bukkit.P;
import pw.yumc.YumCore.config.FileConfig; import pw.yumc.YumCore.config.FileConfig;
/** /**
*
* @since 201699 4:40:50
* @author * @author
* @since 201699 4:40:50
*/ */
public class ChatConfig { public class ChatConfig {
private static String F = "Formats"; private static String F = "Formats";

View File

@ -18,8 +18,8 @@ import pw.yumc.YumCore.tellraw.Tellraw;
/** /**
* *
* *
* @since 201699 4:59:47
* @author * @author
* @since 201699 4:59:47
*/ */
public class ChatRule extends InjectConfigurationSection { public class ChatRule extends InjectConfigurationSection {
private transient static MiaoChat plugin = P.getPlugin(); private transient static MiaoChat plugin = P.getPlugin();
@ -117,7 +117,7 @@ public class ChatRule extends InjectConfigurationSection {
} }
String tempvar = format; String tempvar = format;
for (String var : temp) { for (String var : temp) {
String[] args = tempvar.split("\\[" + var + "]", 2); String[] args = tempvar.split(Pattern.quote("[" + var + "]"), 2);
if (!"".equals(args[0])) { if (!"".equals(args[0])) {
formats.add(args[0]); formats.add(args[0]);
} }

View File

@ -1,5 +1,5 @@
#配置文件版本号 请勿修改 #配置文件版本号 请勿修改
Version: 1.6 Version: 1.8.5
#BC跨服模式 #BC跨服模式
BungeeCord: true BungeeCord: true
@ -7,7 +7,7 @@ BungeeCord: true
Server: '§a生存服' Server: '§a生存服'
#格式列表 #格式列表
Formats: Formats:
#格式名称 对应当前文件夹下的default.yml #格式名称
default: default:
#优先级(将按照从小到大依次检测 比如 1-50 优先检测 1 符合则显示 不符合 检测 2 ...) #优先级(将按照从小到大依次检测 比如 1-50 优先检测 1 符合则显示 不符合 检测 2 ...)
index: 50 index: 50
@ -21,7 +21,7 @@ Formats:
item: true item: true
#物品解析规则 #物品解析规则
itemformat: '&6[&b%s&6]&r' itemformat: '&6[&b%s&6]&r'
#格式名称 对应当前文件夹下的admin.yml #格式名称
admin: admin:
#优先级(将按照从小到大依次检测 比如 1-50 优先检测 1 符合则显示 不符合 检测 2 ...) #优先级(将按照从小到大依次检测 比如 1-50 优先检测 1 符合则显示 不符合 检测 2 ...)
index: 49 index: 49

View 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);
}
}