@Command(
      aliases = {"/smooth"},
      usage = "[iterations]",
      flags = "n",
      desc = "Smooth the elevation in the selection",
      min = 0,
      max = 1)
  @CommandPermissions("worldedit.region.smooth")
  @Logging(REGION)
  public static void smooth(
      CommandContext args,
      WorldEdit we,
      LocalSession session,
      LocalPlayer player,
      EditSession editSession)
      throws WorldEditException {

    int iterations = 1;
    if (args.argsLength() > 0) {
      iterations = args.getInteger(0);
    }

    HeightMap heightMap =
        new HeightMap(editSession, session.getSelection(player.getWorld()), args.hasFlag('n'));
    HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
    int affected = heightMap.applyFilter(filter, iterations);
    player.print("Terrain's height map smoothed. " + affected + " block(s) changed.");
  }