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