mirror of
https://e.coding.net/circlecloud/MiaoChat.git
synced 2024-12-22 19:18:47 +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>
|
<options>
|
||||||
<option>-repackageclasses \ʼ.ʽ.ʾ.${project.artifactId}</option>
|
<option>-repackageclasses \ʼ.ʽ.ʾ.${project.artifactId}</option>
|
||||||
<option>-keep class ${project.groupId}.${project.artifactId}.${project.artifactId}</option>
|
<option>-keep class ${project.groupId}.${project.artifactId}.${project.artifactId}</option>
|
||||||
<option>-keep class
|
<option>-keep class ${project.groupId}.${project.artifactId}.${project.artifactId}Bungee</option>
|
||||||
${project.groupId}.${project.artifactId}.${project.artifactId}Bungee
|
|
||||||
</option>
|
|
||||||
</options>
|
</options>
|
||||||
<libs>
|
<libs>
|
||||||
<lib>${java.home}/lib/rt.jar</lib>
|
<lib>${java.home}/lib/rt.jar</lib>
|
||||||
|
@ -41,9 +41,7 @@ public class ChatRule extends InjectConfigurationSection {
|
|||||||
if (permission == null) {
|
if (permission == null) {
|
||||||
permission = String.format("MiaoChat.%s", name);
|
permission = String.format("MiaoChat.%s", name);
|
||||||
}
|
}
|
||||||
formats = new LinkedList<>();
|
|
||||||
load();
|
load();
|
||||||
lastColor = ChatColor.getLastColors(ChatColor.translateAlternateColorCodes('&', formats.isEmpty() ? "§r" : formats.getLast()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean check(Player player) {
|
public boolean check(Player player) {
|
||||||
@ -91,13 +89,13 @@ public class ChatRule extends InjectConfigurationSection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void load() {
|
private void load() {
|
||||||
|
formats = new LinkedList<>();
|
||||||
Matcher m = FORMAT_PATTERN.matcher(format);
|
Matcher m = FORMAT_PATTERN.matcher(format);
|
||||||
LinkedList<String> temp = new LinkedList<>();
|
LinkedList<String> temp = new LinkedList<>();
|
||||||
while (m.find()) {
|
while (m.find()) {
|
||||||
temp.add(m.group(1));
|
temp.add(m.group(1));
|
||||||
}
|
}
|
||||||
String tempvar = format;
|
String tempvar = format;
|
||||||
if (!temp.isEmpty()) {
|
|
||||||
for (String var : temp) {
|
for (String var : temp) {
|
||||||
String[] args = tempvar.split("\\[" + var + "]", 2);
|
String[] args = tempvar.split("\\[" + var + "]", 2);
|
||||||
if (!"".equals(args[0])) {
|
if (!"".equals(args[0])) {
|
||||||
@ -109,6 +107,6 @@ public class ChatRule extends InjectConfigurationSection {
|
|||||||
if (!tempvar.isEmpty()) {
|
if (!tempvar.isEmpty()) {
|
||||||
formats.add(tempvar);
|
formats.add(tempvar);
|
||||||
}
|
}
|
||||||
}
|
lastColor = ChatColor.getLastColors(ChatColor.translateAlternateColorCodes('&', formats.isEmpty() ? "§r" : formats.getLast()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package pw.yumc.MiaoChat.listeners;
|
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.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -11,6 +14,8 @@ import org.bukkit.event.EventPriority;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
import pw.yumc.MiaoChat.MiaoChat;
|
import pw.yumc.MiaoChat.MiaoChat;
|
||||||
import pw.yumc.MiaoChat.MiaoMessage;
|
import pw.yumc.MiaoChat.MiaoMessage;
|
||||||
import pw.yumc.MiaoChat.config.ChatConfig;
|
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.tellraw.Tellraw;
|
||||||
import pw.yumc.YumCore.update.SubscribeTask;
|
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 class ChatListener implements Listener {
|
||||||
public static Set<String> offList = new HashSet<>();
|
public static Set<String> offList = new HashSet<>();
|
||||||
private static Pattern ITEM_PATTERN = Pattern.compile("%([i1-9]?)");
|
private static Pattern ITEM_PATTERN = Pattern.compile("%([i1-9]?)");
|
||||||
@ -52,8 +53,7 @@ public class ChatListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
Tellraw tr = Tellraw.create();
|
handleChat(p, Tellraw.create(), cr, e.getMessage());
|
||||||
handleChat(p, tr, cr, e.getMessage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleChat(Player p, Tellraw tr, ChatRule cr, String message) {
|
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));
|
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) {
|
private LinkedList<String> handleMessage(LinkedList<String> il, String message) {
|
||||||
|
Loading…
Reference in New Issue
Block a user