diff --git a/pom.xml b/pom.xml
index a5750c6..9ec3b67 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
ChatEx
2022
- 2.8.9
+ 2.9.0
ChatManagement plugin for Bukkit
https://www.spigotmc.org/resources/chatex-continued.71041/
@@ -40,7 +40,11 @@
org.bstats
- de.jeter.chatex
+ de.jeter.chatex.bstats
+
+
+ de.jeter.updatechecker
+ de.jeter.chatex.updatechecker
diff --git a/src/main/java/de/jeter/chatex/ChatListener.java b/src/main/java/de/jeter/chatex/ChatListener.java
index 237fe01..a1a85d3 100644
--- a/src/main/java/de/jeter/chatex/ChatListener.java
+++ b/src/main/java/de/jeter/chatex/ChatListener.java
@@ -41,8 +41,51 @@ public class ChatListener implements Listener {
private final AdManager adManager = Config.ADS_SMART_MANAGER.getBoolean() ? new SmartAdManager() : new SimpleAdManager();
private final BlockedWords blockedWords = new BlockedWords();
+
+ @EventHandler(priority = EventPriority.LOWEST)
+ public void onLowest(final AsyncPlayerChatEvent event) {
+ if (Config.PRIORITY.getString().equalsIgnoreCase("LOWEST")) {
+ executeChatEvent(event);
+ }
+ }
+
+ @EventHandler(priority = EventPriority.LOW)
+ public void onLow(final AsyncPlayerChatEvent event) {
+ if (Config.PRIORITY.getString().equalsIgnoreCase("LOW")) {
+ executeChatEvent(event);
+ }
+ }
+
+ @EventHandler(priority = EventPriority.NORMAL)
+ public void onNormal(final AsyncPlayerChatEvent event) {
+ if (Config.PRIORITY.getString().equalsIgnoreCase("NORMAL")) {
+ executeChatEvent(event);
+ }
+ }
+
+ @EventHandler(priority = EventPriority.HIGH)
+ public void onHigh(final AsyncPlayerChatEvent event) {
+ if (Config.PRIORITY.getString().equalsIgnoreCase("HIGH")) {
+ executeChatEvent(event);
+ }
+ }
+
@EventHandler(priority = EventPriority.HIGHEST)
- public void onChat(final AsyncPlayerChatEvent event) {
+ public void onHighest(final AsyncPlayerChatEvent event) {
+ if (Config.PRIORITY.getString().equalsIgnoreCase("HIGHEST")) {
+ executeChatEvent(event);
+ }
+ }
+
+ @EventHandler(priority = EventPriority.MONITOR)
+ public void onMonitor(final AsyncPlayerChatEvent event) {
+ if (Config.PRIORITY.getString().equalsIgnoreCase("MONITOR")) {
+ executeChatEvent(event);
+ }
+ }
+
+ private void executeChatEvent(AsyncPlayerChatEvent event) {
+ LogHelper.debug("ChatEvent fired with priority: " + Config.PRIORITY.getString().toUpperCase() + ", ChatEx reacting to it...");
Player player = event.getPlayer();
if (!player.hasPermission("chatex.allowchat")) {
@@ -53,6 +96,9 @@ public void onChat(final AsyncPlayerChatEvent event) {
}
String format = PluginManager.getInstance().getMessageFormat(event.getPlayer());
+ LogHelper.debug("Format: " + format);
+ LogHelper.debug("Prefix: " + PluginManager.getInstance().getPrefix(event.getPlayer()));
+ LogHelper.debug("Suffix: " + PluginManager.getInstance().getSuffix(event.getPlayer()));
String chatMessage = event.getMessage();
@@ -70,6 +116,8 @@ public void onChat(final AsyncPlayerChatEvent event) {
}
AntiSpamManager.getInstance().put(player);
+ LogHelper.debug("Player did not activate the AntiSpam. Continuing...");
+
if (adManager.checkForAds(chatMessage, player)) {
String message = Locales.MESSAGES_AD.getString(null).replaceAll("%perm", "chatex.bypassads");
MessageBlockedByAdManagerEvent messageBlockedByAdManagerEvent = new MessageBlockedByAdManagerEvent(player, chatMessage, message);
@@ -82,6 +130,8 @@ public void onChat(final AsyncPlayerChatEvent event) {
}
}
+ LogHelper.debug("Player did not activate the AdBlocker. Continuing...");
+
if (blockedWords.isBlocked(chatMessage)) {
String message = Locales.MESSAGES_BLOCKED.getString(null);
MessageContainsBlockedWordEvent messageContainsBlockedWordEvent = new MessageContainsBlockedWordEvent(player, chatMessage, message);
@@ -94,9 +144,12 @@ public void onChat(final AsyncPlayerChatEvent event) {
}
}
+ LogHelper.debug("Player did not use a blocked word. Continuing...");
+
boolean global = false;
if (Config.RANGEMODE.getBoolean() || Config.BUNGEECORD.getBoolean()) {
if (chatMessage.startsWith(Config.RANGEPREFIX.getString())) {
+ LogHelper.debug("Global mode enabled!");
if (player.hasPermission("chatex.chat.global")) {
chatMessage = chatMessage.replaceFirst(Pattern.quote(Config.RANGEPREFIX.getString()), "");
format = PluginManager.getInstance().getGlobalMessageFormat(player);
@@ -117,6 +170,7 @@ public void onChat(final AsyncPlayerChatEvent event) {
}
} else {
if (Config.RANGEMODE.getBoolean()) {
+ LogHelper.debug("Range mode enabled!");
event.getRecipients().clear();
if (Utils.getLocalRecipients(player).size() == 1 && Config.SHOW_NO_RECEIVER_MSG.getBoolean()) {
player.sendMessage(Locales.NO_LISTENING_PLAYERS.getString(player));
@@ -138,13 +192,16 @@ public void onChat(final AsyncPlayerChatEvent event) {
}
if (global && Config.BUNGEECORD.getBoolean()) {
+ LogHelper.debug("Local mode & Bungeecord mode enabled! Spreading Cross server message...");
String msgToSend = Utils.replacePlayerPlaceholders(player, format.replaceAll("%message", Matcher.quoteReplacement(chatMessage)));
ChannelHandler.getInstance().sendMessage(player, msgToSend);
}
+ LogHelper.debug("Replacing Placeholder in format...");
format = Utils.replacePlayerPlaceholders(player, format);
format = Utils.escape(format);
format = format.replace("%%message", "%2$s");
+ LogHelper.debug("Format after replacing: " + format);
try {
@@ -158,6 +215,7 @@ public void onChat(final AsyncPlayerChatEvent event) {
event.setMessage(Utils.translateColorCodes(chatMessage, player));
ChatLogger.writeToFile(player, chatMessage);
+ LogHelper.debug("Everything done! Method end.");
}
}
diff --git a/src/main/java/de/jeter/chatex/utils/Config.java b/src/main/java/de/jeter/chatex/utils/Config.java
index 4b8941c..04b25f2 100644
--- a/src/main/java/de/jeter/chatex/utils/Config.java
+++ b/src/main/java/de/jeter/chatex/utils/Config.java
@@ -21,6 +21,7 @@
import de.jeter.chatex.ChatEx;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
+import org.bukkit.event.EventPriority;
import java.io.File;
import java.io.IOException;
@@ -44,6 +45,7 @@ public enum Config {
RANGE("chat-range", 100, "The range to talk to other players. Set to -1 to enable world-wide-chat"),
LOGCHAT("logChat", false, "Should the chat be logged?"),
DEBUG("debug", false, "Should the debug log be enabled?"),
+ PRIORITY("EventPriority", EventPriority.NORMAL.name(), "Choose the Eventpriority here of ChatEx. Listeners are called in following order: LOWEST -> LOW -> NORMAL -> HIGH -> HIGHEST -> MONITOR"),
LOCALE("Locale", "en-EN", "Which language do you want? (You can choose betwenn de-DE, fr-FR, pt-BR, zh-CN and en-EN by default.)"),
ADS_ENABLED("Ads.Enabled", true, "Should we check for ads?"),
ADS_BYPASS("Ads.Bypass", Arrays.asList("127.0.0.1", "my-domain.com"), "A list with allowed ips or domains."),
diff --git a/src/main/java/de/jeter/chatex/utils/Utils.java b/src/main/java/de/jeter/chatex/utils/Utils.java
index 64faf25..79770e3 100644
--- a/src/main/java/de/jeter/chatex/utils/Utils.java
+++ b/src/main/java/de/jeter/chatex/utils/Utils.java
@@ -62,7 +62,9 @@ public static String replacePlayerPlaceholders(Player player, String format) {
String result = format;
if (HookManager.checkPlaceholderAPI()) {
+ LogHelper.debug("PlaceholderAPI is installed! Replacing...");
result = PlaceholderAPI.setPlaceholders(player, result);
+ LogHelper.debug("Result: " + result);
}
if ((HookManager.checkEssentials() || HookManager.checkPurpur()) && Config.AFK_PLACEHOLDER.getBoolean()) {