@Command(
      aliases = {"/fillr"},
      usage = "<block> <radius> [depth]",
      desc = "Fill a hole recursively",
      min = 2,
      max = 3)
  @CommandPermissions("worldedit.fill.recursive")
  @Logging(PLACEMENT)
  public void fillr(
      CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession)
      throws WorldEditException {

    Pattern pattern = we.getBlockPattern(player, args.getString(0));
    double radius = Math.max(1, args.getDouble(1));
    we.checkMaxRadius(radius);
    int depth = args.argsLength() > 2 ? Math.max(1, args.getInteger(2)) : 1;

    Vector pos = session.getPlacementPosition(player);
    int affected = 0;
    if (pattern instanceof SingleBlockPattern) {
      affected =
          editSession.fillXZ(pos, ((SingleBlockPattern) pattern).getBlock(), radius, depth, true);
    } else {
      affected = editSession.fillXZ(pos, pattern, radius, depth, true);
    }
    player.print(affected + " block(s) have been created.");
  }
  @Command(
      aliases = {"/fixwater", "fixwater"},
      usage = "<radius>",
      desc = "Fix water to be stationary",
      min = 1,
      max = 1)
  @CommandPermissions("worldedit.fixwater")
  @Logging(PLACEMENT)
  public void fixWater(
      CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession)
      throws WorldEditException {

    double radius = Math.max(0, args.getDouble(0));
    we.checkMaxRadius(radius);
    int affected = editSession.fixLiquid(session.getPlacementPosition(player), radius, 8, 9);
    player.print(affected + " block(s) have been changed.");
  }
  @Command(
      aliases = {"/drain"},
      usage = "<radius>",
      desc = "Drain a pool",
      min = 1,
      max = 1)
  @CommandPermissions("worldedit.drain")
  @Logging(PLACEMENT)
  public void drain(
      CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession)
      throws WorldEditException {

    double radius = Math.max(0, args.getDouble(0));
    we.checkMaxRadius(radius);
    int affected = editSession.drainArea(session.getPlacementPosition(player), radius);
    player.print(affected + " block(s) have been changed.");
  }
  @Command(
      aliases = {"/removenear", "removenear"},
      usage = "<block> [size]",
      desc = "Remove blocks near you.",
      min = 1,
      max = 2)
  @CommandPermissions("worldedit.removenear")
  @Logging(PLACEMENT)
  public void removeNear(
      CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession)
      throws WorldEditException {

    BaseBlock block = we.getBlock(player, args.getString(0), true);
    int size = Math.max(1, args.getInteger(1, 50));
    we.checkMaxRadius(size);

    int affected =
        editSession.removeNear(session.getPlacementPosition(player), block.getType(), size);
    player.print(affected + " block(s) have been removed.");
  }
  @Command(
      aliases = {"/ex", "/ext", "/extinguish", "ex", "ext", "extinguish"},
      usage = "[radius]",
      desc = "Extinguish nearby fire",
      min = 0,
      max = 1)
  @CommandPermissions("worldedit.extinguish")
  @Logging(PLACEMENT)
  public void extinguish(
      CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession)
      throws WorldEditException {

    LocalConfiguration config = we.getConfiguration();

    int defaultRadius = config.maxRadius != -1 ? Math.min(40, config.maxRadius) : 40;
    int size = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : defaultRadius;
    we.checkMaxRadius(size);

    int affected = editSession.removeNear(session.getPlacementPosition(player), 51, size);
    player.print(affected + " block(s) have been removed.");
  }
  @Command(
      aliases = {"/removebelow", "removebelow"},
      usage = "[size] [height]",
      desc = "Remove blocks below you.",
      min = 0,
      max = 2)
  @CommandPermissions("worldedit.removebelow")
  @Logging(PLACEMENT)
  public void removeBelow(
      CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession)
      throws WorldEditException {

    int size = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 1;
    we.checkMaxRadius(size);
    LocalWorld world = player.getWorld();
    int height =
        args.argsLength() > 1
            ? Math.min((world.getMaxY() + 1), args.getInteger(1) + 2)
            : (world.getMaxY() + 1);

    int affected = editSession.removeBelow(session.getPlacementPosition(player), size, height);
    player.print(affected + " block(s) have been removed.");
  }