package com.elmakers.mine.bukkit.magic.command.config;

import java.util.logging.Level;

import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.Plugin;

import com.elmakers.mine.bukkit.api.magic.MageController;

public class AsyncProcessor {
    public static void success(MageController controller, CommandSender sender, String message) {
        message(controller, sender, message);
    }

    public static void message(MageController controller, CommandSender sender, String message) {
        final Plugin plugin = controller.getPlugin();
        plugin.getServer().getScheduler().runTask(plugin, new Runnable() {
            @Override
            public void run() {
                sender.sendMessage(message);
            }
        });
    }

    public static void fail(MageController controller, CommandSender sender, String message) {
        fail(controller, sender, message, null, null);
    }

    public static void fail(MageController controller, CommandSender sender, String message, String errorMessage, Exception ex) {
        final Plugin plugin = controller.getPlugin();
        plugin.getServer().getScheduler().runTask(plugin, new Runnable() {
            @Override
            public void run() {
                sender.sendMessage(ChatColor.RED + message);
                if (errorMessage != null) {
                    controller.getLogger().log(Level.WARNING, errorMessage, ex);
                }
            }
        });
    }
}

@@ -186,16 +186,64 @@
 lugin;%0A%0A
+import com.elmakers.mine.bukkit.api.magic.Mage;%0A
 import c
@@ -292,16 +292,16 @@
 roller;%0A
-
 %0Apublic 
@@ -763,38 +763,174 @@
                 
-sender
+// Allow for chat components and other special message processing%0A                Mage mage = controller.getMage(sender);%0A                mage
 .sendMessage(mes
@@ -1455,22 +1455,158 @@
         
-sender
+// Allow for chat components and other special message processing%0A                Mage mage = controller.getMage(sender);%0A                mage
 .sendMes

Allow chat component processing in async result messaging