package myessentials.utils;

import myessentials.Localization;
import net.minecraft.command.ICommandSender;
import net.minecraft.util.ChatComponentText;

/**
 * Useful methods for Chat
 */
public class ChatUtils {

    private ChatUtils() {

    }

    /**
     * Sends msg to sender.<br />
     * This method will split the message at newline chars (\n) and send each line as a separate message.
     */
    public static void sendChat(ICommandSender sender, String msg, Object... args) {
        if (sender == null) return;
        String[] lines;
        if(args == null)
            lines = msg.split("\\\\n");
        else
            lines = String.format(msg, args).split("\\\\n");
        for (String line : lines) {
            sender.addChatMessage(new ChatComponentText(line));
        }
    }

    /**
     * Sends a localized msg to sender
     * @see ChatUtils#sendChat(net.minecraft.command.ICommandSender, String, Object...)
     */
    public static void sendLocalizedChat(ICommandSender sender, Localization local, String key, Object... args) {
        ChatUtils.sendChat(sender, local.getLocalization(key), args);
    }

    /**
     * Returns true if arg equals on, enable, true, or t. False otherwise.
     */
    // TODO: Overside equal maybe?
    // TODO Change name/change location?
    public static boolean equalsOn(String arg, boolean caseSensitive) {
        if (!caseSensitive)
            arg = arg.toLowerCase();
        return "on".equals(arg) || "enable".equals(arg) || "true".equals(arg) || "t".equals(arg);
    }

    /**
     * Same as {@link ChatUtils#equalsOn(String, boolean)}, but is not case sensitive
     */
    public static boolean equalsOn(String arg) {
        return equalsOn(arg, false);
    }
}

@@ -59,16 +59,55 @@
 ation;%0D%0A
+import myessentials.MyEssentialsCore;%0D%0A
 import n
@@ -628,18 +628,20 @@
 == null)
+ %7B
 %0D%0A
-
         
@@ -684,13 +684,17 @@
     
+ %7D
  else
+ %7B
 %0D%0A  
@@ -745,32 +745,62 @@
 plit(%22%5C%5C%5C%5Cn%22);%0D%0A
+        %7D%0D%0A        try %7B%0D%0A    
         for (Str
@@ -816,24 +816,28 @@
 : lines) %7B%0D%0A
+    
             
@@ -885,24 +885,172 @@
 xt(line));%0D%0A
+            %7D%0D%0A        %7D catch (Exception ex) %7B%0D%0A            MyEssentialsCore.instance.LOG.error(%22Failed to send chat message! Message: %7B%7D%22, msg);%0D%0A
         %7D%0D%0A 

Should fix #334