From 56ad872333ed4d78ec6c55f72d17e93bde5ab586 Mon Sep 17 00:00:00 2001 From: lloyddominic26 Date: Tue, 27 Jul 2021 21:26:20 +0800 Subject: [PATCH 1/3] Transferred island level chat prefix variable replace from Event Priority LOWEST to Event Priority HIGH for better compatibility with other chat formatting plugin --- .../askyblock/listeners/ChatListener.java | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/src/com/wasteofplastic/askyblock/listeners/ChatListener.java b/src/com/wasteofplastic/askyblock/listeners/ChatListener.java index 3e352a19a..8e150893c 100644 --- a/src/com/wasteofplastic/askyblock/listeners/ChatListener.java +++ b/src/com/wasteofplastic/askyblock/listeners/ChatListener.java @@ -96,8 +96,27 @@ public ChatListener(ASkyBlock plugin) { @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onChat(final AsyncPlayerChatEvent event) { + // Team chat + if (Settings.teamChat && teamChatUsers.containsKey(event.getPlayer().getUniqueId())) { + if (DEBUG) + plugin.getLogger().info("DEBUG: team chat"); + // Cancel the event + event.setCancelled(true); + // Queue the sync task because you cannot use HashMaps asynchronously. Delaying to the next tick + // won't be a major issue for synch events either. + Bukkit.getScheduler().runTask(plugin, new Runnable() { + @Override + public void run() { + teamChat(event,event.getMessage()); + }}); + } + } + + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + public void onChatHigh(final AsyncPlayerChatEvent event) { if (DEBUG) plugin.getLogger().info("DEBUG: " + event.getEventName()); + // Substitute variable - thread safe String level = ""; if (playerLevels.containsKey(event.getPlayer().getUniqueId())) { @@ -121,6 +140,7 @@ public void onChat(final AsyncPlayerChatEvent event) { plugin.getLogger().info("DEBUG: getFormat = " + event.getFormat()); plugin.getLogger().info("DEBUG: getMessage = " + event.getMessage()); } + String format = event.getFormat(); if (!Settings.chatLevelPrefix.isEmpty()) { format = format.replace(Settings.chatLevelPrefix, level); @@ -134,25 +154,11 @@ public void onChat(final AsyncPlayerChatEvent event) { } format = format.replace(Settings.chatChallengeLevelPrefix, level); if (DEBUG) - plugin.getLogger().info("DEBUG: format (challenge level sub) = " + format); + plugin.getLogger().info("DEBUG: format (challenge level sub) = " + format); } event.setFormat(format); if (DEBUG) plugin.getLogger().info("DEBUG: format set"); - // Team chat - if (Settings.teamChat && teamChatUsers.containsKey(event.getPlayer().getUniqueId())) { - if (DEBUG) - plugin.getLogger().info("DEBUG: team chat"); - // Cancel the event - event.setCancelled(true); - // Queue the sync task because you cannot use HashMaps asynchronously. Delaying to the next tick - // won't be a major issue for synch events either. - Bukkit.getScheduler().runTask(plugin, new Runnable() { - @Override - public void run() { - teamChat(event,event.getMessage()); - }}); - } } private void teamChat(final AsyncPlayerChatEvent event, String message) { From 658e340436ba9eb6aa984109ff45831ed856b83d Mon Sep 17 00:00:00 2001 From: lloyddominic26 Date: Tue, 27 Jul 2021 23:22:31 +0800 Subject: [PATCH 2/3] Replace Bukkit with Spigot API for Player#spigot() --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 9ba4161e2..ec7617c10 100644 --- a/pom.xml +++ b/pom.xml @@ -108,8 +108,8 @@ - org.bukkit - bukkit + org.spigotmc + spigot-api 1.12.2-R0.1-SNAPSHOT provided From 835cba4f0376035df5e384ef687f00f845116d6e Mon Sep 17 00:00:00 2001 From: lloyddominic26 Date: Tue, 27 Jul 2021 23:40:15 +0800 Subject: [PATCH 3/3] Revert "Replace Bukkit with Spigot API for Player#spigot()" This reverts commit 658e340436ba9eb6aa984109ff45831ed856b83d. --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index ec7617c10..9ba4161e2 100644 --- a/pom.xml +++ b/pom.xml @@ -108,8 +108,8 @@ - org.spigotmc - spigot-api + org.bukkit + bukkit 1.12.2-R0.1-SNAPSHOT provided