commit
dde6a11bf3
6
pom.xml
6
pom.xml
|
@ -3,7 +3,7 @@
|
||||||
<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</version>
|
<version>1.5.1</version>
|
||||||
<build>
|
<build>
|
||||||
<finalName>${project.name}</finalName>
|
<finalName>${project.name}</finalName>
|
||||||
<resources>
|
<resources>
|
||||||
|
@ -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>
|
||||||
|
|
|
@ -18,7 +18,7 @@ import pw.yumc.YumCore.config.inject.InjectConfigurationSection;
|
||||||
* @author 喵♂呜
|
* @author 喵♂呜
|
||||||
*/
|
*/
|
||||||
public class ChatRule extends InjectConfigurationSection {
|
public class ChatRule extends InjectConfigurationSection {
|
||||||
private transient static Pattern FORMAT_PATTERN = Pattern.compile("[\\[]([^\\[\\]]+)[\\]]");
|
private transient static Pattern FORMAT_PATTERN = Pattern.compile("[\\[]([^\\[\\]]+)[]]");
|
||||||
private transient String name;
|
private transient String name;
|
||||||
@Default("50")
|
@Default("50")
|
||||||
private Integer index;
|
private Integer index;
|
||||||
|
@ -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.getLast()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean check(Player player) {
|
public boolean check(Player player) {
|
||||||
|
@ -91,15 +89,15 @@ 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]);
|
||||||
}
|
}
|
||||||
|
@ -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