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