@Override
  public boolean onCommand(
      CommandSender sender, Command command, String commandLabel, String[] args) {
    // Event handling
    CouponCodesCommandEvent ev =
        EventHandle.callCouponCodesCommandEvent(sender, command, commandLabel, args);
    if (ev.isCancelled()) return true;
    sender = ev.getSender();
    command = ev.getCommand();
    commandLabel = ev.getCommandLabel();
    args = ev.getArgs();

    if (args.length == 0) {
      help(sender);
      return true;
    }

    boolean pl = false;
    if (sender instanceof Player) pl = true;

    // Add command 2.0
    if (args[0].equalsIgnoreCase("add")) {
      if (args.length < 2) {
        helpAdd(sender);
        return true;
      }
      if (has(sender, "cc.add")) {
        server
            .getScheduler()
            .scheduleAsyncDelayedTask(this, new QuedAddCommand(this, sender, args));
        return true;
      } else {
        sender.sendMessage(ChatColor.RED + "You do not have permission to use this command.");
        return true;
      }
    }

    // Remove command
    else if (args[0].equalsIgnoreCase("remove")) {
      if (has(sender, "cc.remove")) {
        server.getScheduler().scheduleAsyncDelayedTask(this, new QuedRemoveCommand(sender, args));
        return true;
      } else {
        sender.sendMessage(ChatColor.RED + "You do not have permission to use this command");
        return true;
      }
    }

    // Redeem command
    else if (args[0].equalsIgnoreCase("redeem")) {
      if (!pl) {
        sender.sendMessage("You must be a player to redeem a coupon");
        return true;
      } else {
        Player player = (Player) sender;
        if (has(player, "cc.redeem")) {
          server
              .getScheduler()
              .scheduleAsyncDelayedTask(this, new QuedRedeemCommand(this, player, args));
          return true;
        } else {
          player.sendMessage(ChatColor.RED + "You do not have permission to use this command");
          return true;
        }
      }
    }

    // List command
    else if (args[0].equalsIgnoreCase("list")) {
      if (has(sender, "cc.list")) {
        server.getScheduler().scheduleAsyncDelayedTask(this, new QuedListCommand(sender));
        return true;
      } else {
        sender.sendMessage(ChatColor.RED + "You do not have permission to use this command");
        return true;
      }
    }

    // Info command
    else if (args[0].equalsIgnoreCase("info")) {
      if (has(sender, "cc.info")) {
        server
            .getScheduler()
            .scheduleAsyncDelayedTask(this, new QuedInfoCommand(this, sender, args));
        return true;
      } else {
        sender.sendMessage(ChatColor.RED + "You do not have permission to use this command");
        return true;
      }
    }

    // Reload command
    else if (args[0].equalsIgnoreCase("reload")) {
      if (has(sender, "cc.reload")) {
        if (!sql.reload()) sender.sendMessage(ChatColor.DARK_RED + "Could not reload the database");
        else sender.sendMessage(ChatColor.GREEN + "Database reloaded");
        reloadConfig();
        config = new Config(this);
        debug = config.getDebug();
        sender.sendMessage(ChatColor.GREEN + "Config reloaded");
        return true;
      } else {
        sender.sendMessage(ChatColor.RED + "You do not have permission to use this command");
        return true;
      }
    } else {
      help(sender);
      return true;
    }
  }