mirror of
https://e.coding.net/circlecloud/MiaoChat.git
synced 2024-11-21 14:28:46 +00:00
fix: 修复空指针
Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
parent
4538653914
commit
8ee853c1cf
4
pom.xml
4
pom.xml
@ -62,9 +62,7 @@
|
||||
<options>
|
||||
<option>-repackageclasses \ʼ.ʽ.ʾ.${project.artifactId}</option>
|
||||
<option>-keep class ${project.groupId}.${project.artifactId}.${project.artifactId}</option>
|
||||
<option>-keep class
|
||||
${project.groupId}.${project.artifactId}.${project.artifactId}Bungee
|
||||
</option>
|
||||
<option>-keep class ${project.groupId}.${project.artifactId}.${project.artifactId}Bungee</option>
|
||||
</options>
|
||||
<libs>
|
||||
<lib>${java.home}/lib/rt.jar</lib>
|
||||
|
@ -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,13 +89,13 @@ public class ChatRule extends InjectConfigurationSection {
|
||||
}
|
||||
|
||||
private void load() {
|
||||
formats = new LinkedList<>();
|
||||
Matcher m = FORMAT_PATTERN.matcher(format);
|
||||
LinkedList<String> 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])) {
|
||||
@ -109,6 +107,6 @@ public class ChatRule extends InjectConfigurationSection {
|
||||
if (!tempvar.isEmpty()) {
|
||||
formats.add(tempvar);
|
||||
}
|
||||
}
|
||||
lastColor = ChatColor.getLastColors(ChatColor.translateAlternateColorCodes('&', formats.isEmpty() ? "§r" : formats.getLast()));
|
||||
}
|
||||
}
|
||||
|
@ -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<String> 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<String> handleMessage(LinkedList<String> il, String message) {
|
||||
|
Loading…
Reference in New Issue
Block a user