/**
   * Construct a CommandHandler instance
   *
   * @param commands
   */
  public CommandHandler(ArrayList<Command> commands) {
    WindowManager.getDebugWindow().printInfo("Registering commands");

    for (Command c : commands) {
      registerCommand(c);
    }

    WindowManager.getDebugWindow().printInfo(commands.size() + " commands registered");
  }
  /**
   * Parse command.
   *
   * @param command
   */
  public void parseCommand(String command) {
    boolean isCommand = false;

    String[] s = command.split(" ", 2);

    for (Command c : commands) {
      if (c.getCommand().equalsIgnoreCase(s[0])) {
        c.getCommandAction().onRun(c, command);
        isCommand = true;
      }
    }

    if (!isCommand) {
      WindowManager.getDebugWindow().printError("'" + command + "' is not a registered command");
    }
  }