From 56ad872333ed4d78ec6c55f72d17e93bde5ab586 Mon Sep 17 00:00:00 2001 From: lloyddominic26 Date: Tue, 27 Jul 2021 21:26:20 +0800 Subject: [PATCH 1/5] 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/5] 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/5] 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 From 818803a5f33d0c0804ad69f527edb9dd24bfc376 Mon Sep 17 00:00:00 2001 From: lloyddominic26 Date: Wed, 28 Jul 2021 00:00:39 +0800 Subject: [PATCH 4/5] 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 dad9c01c135e01bb24a43be8051a4290dbebfb94 Mon Sep 17 00:00:00 2001 From: lloyddominic26 Date: Wed, 28 Jul 2021 00:06:46 +0800 Subject: [PATCH 5/5] Fixed no color in action bar, Replaced dispatch command method for action bar with native method from Spigot API --- src/com/wasteofplastic/askyblock/util/Util.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/com/wasteofplastic/askyblock/util/Util.java b/src/com/wasteofplastic/askyblock/util/Util.java index a94e1707e..587e070c1 100644 --- a/src/com/wasteofplastic/askyblock/util/Util.java +++ b/src/com/wasteofplastic/askyblock/util/Util.java @@ -45,6 +45,9 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.scheduler.BukkitTask; +import net.md_5.bungee.api.ChatMessageType; +import net.md_5.bungee.api.chat.TextComponent; + import com.wasteofplastic.askyblock.ASkyBlock; import com.wasteofplastic.askyblock.Settings; import com.wasteofplastic.askyblock.nms.NMSAbstraction; @@ -509,8 +512,7 @@ public static void sendEnterExit(Player player, String message) { sendMessage(player, message); return; } - plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), - "minecraft:title " + player.getName() + " actionbar {\"text\":\"" + ChatColor.stripColor(message) + "\"}"); + player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&', message))); } /**