@Command(
      aliases = {"/copy"},
      flags = "em",
      desc = "Copy the selection to the clipboard",
      help =
          "Copy the selection to the clipboard\n"
              + "Flags:\n"
              + "  -e controls whether entities are copied\n"
              + "  -m sets a source mask so that excluded blocks become air\n"
              + "WARNING: Pasting entities cannot yet be undone!",
      min = 0,
      max = 0)
  @CommandPermissions("worldedit.clipboard.copy")
  public void copy(
      Player player,
      LocalSession session,
      EditSession editSession,
      @Selection Region region,
      @Switch('e') boolean copyEntities,
      @Switch('m') Mask mask)
      throws WorldEditException {

    BlockArrayClipboard clipboard = new BlockArrayClipboard(region);
    clipboard.setOrigin(session.getPlacementPosition(player));
    ForwardExtentCopy copy =
        new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
    if (mask != null) {
      copy.setSourceMask(mask);
    }
    Operations.completeLegacy(copy);
    session.setClipboard(new ClipboardHolder(clipboard, editSession.getWorld().getWorldData()));

    player.print(region.getArea() + " block(s) were copied.");
  }
  @Command(
      aliases = {"/paste"},
      usage = "",
      flags = "sao",
      desc = "Paste the clipboard's contents",
      help =
          "Pastes the clipboard's contents.\n"
              + "Flags:\n"
              + "  -a skips air blocks\n"
              + "  -o pastes at the original position\n"
              + "  -s selects the region after pasting",
      min = 0,
      max = 0)
  @CommandPermissions("worldedit.clipboard.paste")
  @Logging(PLACEMENT)
  public void paste(
      Player player,
      LocalSession session,
      EditSession editSession,
      @Switch('a') boolean ignoreAirBlocks,
      @Switch('o') boolean atOrigin,
      @Switch('s') boolean selectPasted)
      throws WorldEditException {

    ClipboardHolder holder = session.getClipboard();
    Clipboard clipboard = holder.getClipboard();
    Region region = clipboard.getRegion();

    Vector to = atOrigin ? clipboard.getOrigin() : session.getPlacementPosition(player);
    Operation operation =
        holder
            .createPaste(editSession, editSession.getWorld().getWorldData())
            .to(to)
            .ignoreAirBlocks(ignoreAirBlocks)
            .build();
    Operations.completeLegacy(operation);

    if (selectPasted) {
      Vector clipboardOffset =
          clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
      Vector realTo = to.add(holder.getTransform().apply(clipboardOffset));
      Vector max =
          realTo.add(
              holder
                  .getTransform()
                  .apply(region.getMaximumPoint().subtract(region.getMinimumPoint())));
      RegionSelector selector = new CuboidRegionSelector(player.getWorld(), realTo, max);
      session.setRegionSelector(player.getWorld(), selector);
      selector.learnChanges();
      selector.explainRegionAdjust(player, session);
    }

    player.print("The clipboard has been pasted at " + to);
  }