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
220
pom.xml
220
pom.xml
@ -1,113 +1,111 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>pw.yumc</groupId>
|
||||
<artifactId>MiaoChat</artifactId>
|
||||
<version>1.5.1</version>
|
||||
<build>
|
||||
<finalName>${project.name}</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.3</version>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>2.3</version>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>pw.yumc:YumCore</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>pw.yumc.YumCore</pattern>
|
||||
<shadedPattern>${project.groupId}.${project.artifactId}</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.github.wvengen</groupId>
|
||||
<artifactId>proguard-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>proguard</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<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>
|
||||
</options>
|
||||
<libs>
|
||||
<lib>${java.home}/lib/rt.jar</lib>
|
||||
</libs>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<ciManagement>
|
||||
<system>Jenkins</system>
|
||||
<url>http://ci.yumc.pw/job/${project.artifactId}/</url>
|
||||
</ciManagement>
|
||||
<properties>
|
||||
<update.description></update.description>
|
||||
<update.changes></update.changes>
|
||||
<env.GIT_COMMIT>DEBUG</env.GIT_COMMIT>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>yumc-repo</id>
|
||||
<url>http://repo.yumc.pw/content/groups/public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>jtb</id>
|
||||
<name>YUMC</name>
|
||||
<url>http://repo.yumc.pw/content/repositories/yumcenter/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>pw.yumc</groupId>
|
||||
<artifactId>YumCore</artifactId>
|
||||
<type>jar</type>
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>pw.yumc</groupId>
|
||||
<artifactId>MiaoChat</artifactId>
|
||||
<version>1.5.1</version>
|
||||
<build>
|
||||
<finalName>${project.name}</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.3</version>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>2.3</version>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>pw.yumc:YumCore</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>pw.yumc.YumCore</pattern>
|
||||
<shadedPattern>${project.groupId}.${project.artifactId}</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.github.wvengen</groupId>
|
||||
<artifactId>proguard-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>proguard</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<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>
|
||||
</options>
|
||||
<libs>
|
||||
<lib>${java.home}/lib/rt.jar</lib>
|
||||
</libs>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<ciManagement>
|
||||
<system>Jenkins</system>
|
||||
<url>http://ci.yumc.pw/job/${project.artifactId}/</url>
|
||||
</ciManagement>
|
||||
<properties>
|
||||
<update.description></update.description>
|
||||
<update.changes></update.changes>
|
||||
<env.GIT_COMMIT>DEBUG</env.GIT_COMMIT>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>yumc-repo</id>
|
||||
<url>http://repo.yumc.pw/content/groups/public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>jtb</id>
|
||||
<name>YUMC</name>
|
||||
<url>http://repo.yumc.pw/content/repositories/yumcenter/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>pw.yumc</groupId>
|
||||
<artifactId>YumCore</artifactId>
|
||||
<type>jar</type>
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -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<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])) {
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
@ -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