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.plugin.Command;
import net.md_5.bungee.chat.ComponentSerializer;

import java.util.Arrays;

public class CommandAlertRaw extends Command
{

    public CommandAlertRaw()
    {
        super( "alertraw", "bungeecord.command.alert" );
    }

    @Override
    public void execute(CommandSender sender, String[] args)
    {
        if ( args.length == 0 )
        {
            sender.sendMessage( ChatColor.RED + "You must supply a message." );
        } else
        {
            String message = Joiner.on(' ').join( args );

            try
            {
                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() );
            }
        }
    }
}

@@ -31,46 +31,8 @@
 d;%0A%0A
-import com.google.common.base.Joiner;%0A
 impo
@@ -65,16 +65,16 @@
 tColor;%0A
+
 import n
@@ -273,25 +273,31 @@
 pi.c
-hat.TextComponent
+onnection.ProxiedPlayer
 ;%0Aim
@@ -398,24 +398,37 @@
 ort 
-java.util.Arrays
+com.google.common.base.Joiner
 ;%0A%0Ap
@@ -1025,32 +1025,100 @@
 )%0A            %7B%0A
+            %09if ( sender instanceof ProxiedPlayer )%0A            %09%7B%0A%09
                 
@@ -1137,16 +1137,17 @@
 essage(%0A
+%09
         
@@ -1251,24 +1251,25 @@
 etails)%22 ).%0A
+%09
             
@@ -1327,24 +1327,25 @@
 ed( true ).%0A
+%09
             
@@ -1416,16 +1416,17 @@
 W_TEXT,%0A
+%09
         
@@ -1533,16 +1533,17 @@
 () ) ).%0A
+%09
         
@@ -1574,24 +1574,191 @@
 create() );%0A
+            %09%7D else%0A            %09%7B%0A            %09%09sender.sendMessage(ChatColor.RED + %22An error occurred while parsing your message. %22 + e.getMessage());%0A            %09%7D%0A
             

Fix errors for console