diff --git a/pom.xml b/pom.xml
index efcbc99..370964d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,113 +1,111 @@
- 4.0.0
- pw.yumc
- MiaoChat
- 1.5.1
-
- ${project.name}
-
-
- src/main/resources
- true
-
-
-
-
- maven-compiler-plugin
- 3.3
-
-
- 1.7
-
-
-
- org.apache.maven.plugins
- maven-shade-plugin
- 2.3
-
- false
- true
-
-
- pw.yumc:YumCore
-
-
-
-
- pw.yumc.YumCore
- ${project.groupId}.${project.artifactId}
-
-
-
-
-
- package
-
- shade
-
-
-
-
-
- com.github.wvengen
- proguard-maven-plugin
-
-
- package
-
- proguard
-
-
-
-
-
-
-
-
- ${java.home}/lib/rt.jar
-
-
-
-
-
-
-
-
- Jenkins
- http://ci.yumc.pw/job/${project.artifactId}/
-
-
-
-
- DEBUG
- UTF-8
-
-
-
- spigot-repo
- https://hub.spigotmc.org/nexus/content/groups/public/
-
-
- yumc-repo
- http://repo.yumc.pw/content/groups/public/
-
-
-
-
- jtb
- YUMC
- http://repo.yumc.pw/content/repositories/yumcenter/
-
-
-
-
- pw.yumc
- YumCore
- jar
- 1.2
-
-
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+ pw.yumc
+ MiaoChat
+ 1.5.1
+
+ ${project.name}
+
+
+ src/main/resources
+ true
+
+
+
+
+ maven-compiler-plugin
+ 3.3
+
+
+ 1.7
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 2.3
+
+ false
+ true
+
+
+ pw.yumc:YumCore
+
+
+
+
+ pw.yumc.YumCore
+ ${project.groupId}.${project.artifactId}
+
+
+
+
+
+ package
+
+ shade
+
+
+
+
+
+ com.github.wvengen
+ proguard-maven-plugin
+
+
+ package
+
+ proguard
+
+
+
+
+
+
+
+
+ ${java.home}/lib/rt.jar
+
+
+
+
+
+
+
+
+ Jenkins
+ http://ci.yumc.pw/job/${project.artifactId}/
+
+
+
+
+ DEBUG
+ UTF-8
+
+
+
+ spigot-repo
+ https://hub.spigotmc.org/nexus/content/groups/public/
+
+
+ yumc-repo
+ http://repo.yumc.pw/content/groups/public/
+
+
+
+
+ jtb
+ YUMC
+ http://repo.yumc.pw/content/repositories/yumcenter/
+
+
+
+
+ pw.yumc
+ YumCore
+ jar
+ 1.2
+
+
\ No newline at end of file
diff --git a/src/main/java/pw/yumc/MiaoChat/config/ChatRule.java b/src/main/java/pw/yumc/MiaoChat/config/ChatRule.java
index 23434da..84c91ad 100644
--- a/src/main/java/pw/yumc/MiaoChat/config/ChatRule.java
+++ b/src/main/java/pw/yumc/MiaoChat/config/ChatRule.java
@@ -41,9 +41,7 @@ public class ChatRule extends InjectConfigurationSection {
if (permission == null) {
permission = String.format("MiaoChat.%s", name);
}
- formats = new LinkedList<>();
load();
- lastColor = ChatColor.getLastColors(ChatColor.translateAlternateColorCodes('&', formats.isEmpty() ? "§r" : formats.getLast()));
}
public boolean check(Player player) {
@@ -91,24 +89,24 @@ public class ChatRule extends InjectConfigurationSection {
}
private void load() {
+ formats = new LinkedList<>();
Matcher m = FORMAT_PATTERN.matcher(format);
LinkedList temp = new LinkedList<>();
while (m.find()) {
temp.add(m.group(1));
}
String tempvar = format;
- if (!temp.isEmpty()) {
- for (String var : temp) {
- String[] args = tempvar.split("\\[" + var + "]", 2);
- if (!"".equals(args[0])) {
- formats.add(args[0]);
- }
- formats.add(var);
- tempvar = args[1];
- }
- if (!tempvar.isEmpty()) {
- formats.add(tempvar);
+ for (String var : temp) {
+ String[] args = tempvar.split("\\[" + var + "]", 2);
+ if (!"".equals(args[0])) {
+ formats.add(args[0]);
}
+ formats.add(var);
+ tempvar = args[1];
}
+ if (!tempvar.isEmpty()) {
+ formats.add(tempvar);
+ }
+ lastColor = ChatColor.getLastColors(ChatColor.translateAlternateColorCodes('&', formats.isEmpty() ? "§r" : formats.getLast()));
}
}
diff --git a/src/main/java/pw/yumc/MiaoChat/listeners/ChatListener.java b/src/main/java/pw/yumc/MiaoChat/listeners/ChatListener.java
index f325707..8037127 100644
--- a/src/main/java/pw/yumc/MiaoChat/listeners/ChatListener.java
+++ b/src/main/java/pw/yumc/MiaoChat/listeners/ChatListener.java
@@ -1,6 +1,9 @@
package pw.yumc.MiaoChat.listeners;
-import me.clip.placeholderapi.PlaceholderAPI;
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@@ -11,6 +14,8 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.inventory.ItemStack;
+
+import me.clip.placeholderapi.PlaceholderAPI;
import pw.yumc.MiaoChat.MiaoChat;
import pw.yumc.MiaoChat.MiaoMessage;
import pw.yumc.MiaoChat.config.ChatConfig;
@@ -24,10 +29,6 @@ import pw.yumc.YumCore.statistic.Statistics;
import pw.yumc.YumCore.tellraw.Tellraw;
import pw.yumc.YumCore.update.SubscribeTask;
-import java.util.*;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
public class ChatListener implements Listener {
public static Set offList = new HashSet<>();
private static Pattern ITEM_PATTERN = Pattern.compile("%([i1-9]?)");
@@ -52,8 +53,7 @@ public class ChatListener implements Listener {
return;
}
e.setCancelled(true);
- Tellraw tr = Tellraw.create();
- handleChat(p, tr, cr, e.getMessage());
+ handleChat(p, Tellraw.create(), cr, e.getMessage());
}
private void handleChat(Player p, Tellraw tr, ChatRule cr, String message) {
@@ -76,7 +76,7 @@ public class ChatListener implements Listener {
tr.then(PlaceholderAPI.setPlaceholders(p, format));
}
}
- return ChatColor.getLastColors(formats.getLast());
+ return ChatColor.getLastColors(formats.isEmpty() ? "§r" : formats.getLast());
}
private LinkedList handleMessage(LinkedList il, String message) {