From 888086f4272769e9d0e457abc874e8d163a39a04 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sun, 18 Dec 2016 00:42:45 +0100 Subject: [PATCH] Added fallback if chat processing fails --- .../buttondevteam/chat/listener/PlayerListener.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/buttondevteam/chat/listener/PlayerListener.java b/src/main/java/buttondevteam/chat/listener/PlayerListener.java index 1937981..062c8c0 100644 --- a/src/main/java/buttondevteam/chat/listener/PlayerListener.java +++ b/src/main/java/buttondevteam/chat/listener/PlayerListener.java @@ -28,6 +28,7 @@ import buttondevteam.chat.ChatPlayer; import buttondevteam.chat.ChatProcessing; import buttondevteam.chat.PluginMain; import buttondevteam.lib.TBMCChatEvent; +import buttondevteam.lib.TBMCCoreAPI; import buttondevteam.lib.TBMCPlayer; import buttondevteam.lib.TBMCPlayer.InfoTarget; import buttondevteam.lib.chat.Channel; @@ -337,6 +338,15 @@ public class PlayerListener implements Listener { @EventHandler public void onPlayerTBMCChat(TBMCChatEvent e) { - ChatProcessing.ProcessChat(e.getChannel(), e.getSender(), e.getMessage()); + try { + ChatProcessing.ProcessChat(e.getChannel(), e.getSender(), e.getMessage()); + } catch (Exception ex) { + for (Player p : Bukkit.getOnlinePlayers()) + p.sendMessage("§c!§r[" + + e.getChannel().DisplayName + "] <" + (e.getSender() instanceof Player + ? ((Player) e.getSender()).getDisplayName() : e.getSender().getName()) + + "> " + e.getMessage()); + TBMCCoreAPI.SendException("An error occured while processing a chat message!", ex); + } } }