From 93ba9b3a3e3d00d6f2e7c4643c7c019df20c2b29 Mon Sep 17 00:00:00 2001 From: kosgan10 Date: Mon, 30 Dec 2013 15:36:35 +0200 Subject: [PATCH] Fix errors for console --- .../md_5/bungee/command/CommandAlertRaw.java | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/proxy/src/main/java/net/md_5/bungee/command/CommandAlertRaw.java b/proxy/src/main/java/net/md_5/bungee/command/CommandAlertRaw.java index 0c9ac0e5..0ffb2d2c 100644 --- a/proxy/src/main/java/net/md_5/bungee/command/CommandAlertRaw.java +++ b/proxy/src/main/java/net/md_5/bungee/command/CommandAlertRaw.java @@ -1,16 +1,15 @@ package net.md_5.bungee.command; -import com.google.common.base.Joiner; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.chat.ComponentBuilder; import net.md_5.bungee.api.chat.HoverEvent; -import net.md_5.bungee.api.chat.TextComponent; +import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.plugin.Command; import net.md_5.bungee.chat.ComponentSerializer; -import java.util.Arrays; +import com.google.common.base.Joiner; public class CommandAlertRaw extends Command { @@ -35,12 +34,18 @@ public class CommandAlertRaw extends Command ProxyServer.getInstance().broadcast( ComponentSerializer.parse( message ) ); } catch ( Exception e ) { - sender.sendMessage( - new ComponentBuilder( "An error occurred while parsing your message. (Hover for details)" ). - color( ChatColor.RED ).underlined( true ). - event( new HoverEvent( HoverEvent.Action.SHOW_TEXT, - new ComponentBuilder( e.getMessage() ).color( ChatColor.RED ).create() ) ). - create() ); + if ( sender instanceof ProxiedPlayer ) + { + sender.sendMessage( + new ComponentBuilder( "An error occurred while parsing your message. (Hover for details)" ). + color( ChatColor.RED ).underlined( true ). + event( new HoverEvent( HoverEvent.Action.SHOW_TEXT, + new ComponentBuilder( e.getMessage() ).color( ChatColor.RED ).create() ) ). + create() ); + } else + { + sender.sendMessage(ChatColor.RED + "An error occurred while parsing your message. " + e.getMessage()); + } } } }