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 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) { 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))); } /**