package myessentials.chat.api;

import myessentials.localization.api.LocalManager;
import net.minecraft.command.ICommandSender;
import net.minecraft.util.IChatComponent;
import net.minecraft.entity.player.EntityPlayerMP;

import java.util.List;

public class ChatManager {

    /**
     * Global method for sending localized messages
     */
    public static void send(ICommandSender sender, String localizationKey, Object... args) {
        send(sender, LocalManager.get(localizationKey, args));
    }

    /**
     * Global method for sending messages
     * If the message sent is a ChatComponentList then only its siblings are sent, omitting the root component
     */
    @SuppressWarnings("unchecked")
    public static void send(ICommandSender sender, IChatComponent message) {
        if (sender == null) {
            return;
        }

        if (message == null) {
            return;
        }

        if (message instanceof ChatComponentList) {
            for (IChatComponent sibling : (List<IChatComponent>)message.getSiblings()) {
                if (sibling == null) {
                    continue;
                }

                sender.addChatMessage(sibling);
            }
        } else {
            sender.addChatMessage(message);
        }
    }
    
    public static void addChatMessageFixed(ICommandSender sender, IChatComponent message) {
        if (!(sender instanceof EntityPlayerMP)||((EntityPlayerMP)sender).playerNetServerHandler != null)
            sender.addChatMessage(message);
        } else {
            //TODO Find a way to re-send the message.
        }
    }
}

@@ -1522,35 +1522,25 @@
 );%0A        %7D
- else %7B%0A   
+%0A
          //T
@@ -1578,26 +1578,16 @@
 essage.%0A
-        %7D%0A
     %7D%0A%7D%0A

Update to make Travis-CI happier.