package mondocommand;

import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;

/** 
 * Allow customizing response strings from MondoCommand. 
 * 
 * Creating a FormatConfig is similar to doing so for MondoCommand: use argument chaining.
 * */
public class FormatConfig {
    private String permissionWarning = "{WARNING}You do not have permissions for this command.";
    private String usageHeading = "{HEADER}Usage: ";
    private String replyPrefix = "";

    public FormatConfig() {
        
    }
    
    public String getPermissionWarning() {
        return permissionWarning;
    }
    
    public String getUsageHeading() {
        return usageHeading;
    }
    
    public String getReplyPrefix() {
        return replyPrefix;
    }
    
    
    /**
     * Set the permission warning to be displayed when a user cannot access a command.
     * @param permissionWarning a String which accepts color codes.
     * @return the same FormatConfig, for chaining.
     */
    public FormatConfig setPermissionWarning(String permissionWarning) {
        this.permissionWarning = permissionWarning;
        return this;
    }
    
    /**
     * Set the heading to be shown when displaying command usage.
     * @param usageHeading A string which accepts color codes.
     * @return the same FormatConfig, for chaining.
     */
    public FormatConfig setUsageHeading(String usageHeading) {
        this.usageHeading = usageHeading;
        return this;
    }
    
    /**
     * Set the prefix to be placed before all command replies.
     * @param replyPrefix a String which accepts color codes.
     * @return the same FormatConfig, for chaining
     */
    public FormatConfig setReplyPrefix(String replyPrefix) {
        this.replyPrefix = replyPrefix;
        return this;
    }


    /**
     * Register MondoCommand color aliases upon initialization of the MondoCommand.
     * 
     * This method doesn't make much sense to be called by the user right now, 
     * it's here to support future functionality and/or user customization where colors
     * are concerned.
     */
    public void registerColorAliases() {
        ChatMagic.registerDefaultAlias("{HEADER}", ChatColor.GOLD);
        ChatMagic.registerDefaultAlias("{USAGE}", ChatColor.LIGHT_PURPLE);
        ChatMagic.registerDefaultAlias("{WARNING}", ChatColor.DARK_RED);
        ChatMagic.registerDefaultAlias("{ERROR}", ChatColor.RED);
        ChatMagic.registerDefaultAlias("{NOUN}", ChatColor.AQUA);
        ChatMagic.registerDefaultAlias("{VERB}", ChatColor.GRAY);
        ChatMagic.registerDefaultAlias("{DESCRIPTION}", ChatColor.BLUE);
    }

    /**
     * Write out one entry of the usage output.
     * 
     * <p>This method exists so that users can subclass it and do their own
     * formatting of MondoCommand's usage output. It's the responsibility of
     * this method to also send the usage output, this way customized line wrapping,
     * multi-line messages, etc can be implemented.
     * 
     * @param sender The CommandSender requesting usage.
     * @param commandLabel The current base command label. Will be prefixed with a / if a player command.
     * @param sub The SubCommand we're generating a usage screen for.
     * @return A formatted single usage line.
     */
    public void writeUsageLine(CommandSender sender, String commandLabel, SubCommand sub) {
        String usage = "";
        if (sub.getUsage() != null) {
            usage = ChatMagic.colorize(" {USAGE}%s", sub.getUsage());
        }
        ChatMagic.send(sender,
            "{GREEN}%s %s%s {DESCRIPTION}%s",
            commandLabel,
            sub.getName(),
            usage,
            sub.getDescription()
        );
    }
}

@@ -1095,24 +1095,69 @@
 nWarning) %7B%0A
+        Validate.notNull(permissionWarning);%0A
         this
@@ -1192,24 +1192,24 @@
 ionWarning;%0A
-
         retu
@@ -1484,24 +1484,64 @@
 eHeading) %7B%0A
+        Validate.notNull(usageHeading);%0A
         this
@@ -1851,24 +1851,63 @@
 lyPrefix) %7B%0A
+        Validate.notNull(replyPrefix);%0A
         this
@@ -2716,16 +2716,83 @@
 .GRAY);%0A
+        ChatMagic.registerDefaultAlias(%22%7BMCMD%7D%22, ChatColor.GREEN);%0A
         
@@ -3798,17 +3798,22 @@
   %22%7B
-GREEN%7D%25s 
+MCMD%7D%25s %7BVERB%7D
 %25s%25s

Add some validation, update format config