コード例 #1
0
  @Command(
      aliases = {"clipboard", "copy"},
      usage = "",
      desc = "Choose the clipboard brush",
      help =
          "Chooses the clipboard brush.\n"
              + "The -a flag makes it not paste air.\n"
              + "Without the -p flag, the paste will appear centered at the target location. "
              + "With the flag, then the paste will appear relative to where you had "
              + "stood relative to the copied area when you copied it.")
  @CommandPermissions("worldedit.brush.clipboard")
  public void clipboardBrush(
      Player player,
      LocalSession session,
      EditSession editSession,
      @Switch('a') boolean ignoreAir,
      @Switch('p') boolean usingOrigin)
      throws WorldEditException {
    ClipboardHolder holder = session.getClipboard();
    Clipboard clipboard = holder.getClipboard();

    Vector size = clipboard.getDimensions();

    worldEdit.checkMaxBrushRadius(size.getBlockX());
    worldEdit.checkMaxBrushRadius(size.getBlockY());
    worldEdit.checkMaxBrushRadius(size.getBlockZ());

    BrushTool tool = session.getBrushTool(player.getItemInHand());
    tool.setBrush(new ClipboardBrush(holder, ignoreAir, usingOrigin), "worldedit.brush.clipboard");

    player.print("Clipboard brush shape equipped.");
  }
コード例 #2
0
  @Command(
      aliases = {"gravity", "grav"},
      usage = "[radius]",
      flags = "h",
      desc = "Gravity brush",
      help =
          "This brush simulates the affect of gravity.\n"
              + "The -h flag makes it affect blocks starting at the world's max y, "
              + "instead of the clicked block's y + radius.",
      min = 0,
      max = 1)
  @CommandPermissions("worldedit.brush.gravity")
  public void gravityBrush(
      Player player,
      LocalSession session,
      EditSession editSession,
      @Optional("5") double radius,
      @Switch('h') boolean fromMaxY)
      throws WorldEditException {
    worldEdit.checkMaxBrushRadius(radius);

    BrushTool tool = session.getBrushTool(player.getItemInHand());
    tool.setSize(radius);
    tool.setBrush(new GravityBrush(fromMaxY), "worldedit.brush.gravity");

    player.print(String.format("Gravity brush equipped (%.0f).", radius));
  }
コード例 #3
0
  @Command(
      aliases = {"/rotate"},
      usage = "<y-axis> [<x-axis>] [<z-axis>]",
      desc = "Rotate the contents of the clipboard",
      help =
          "Non-destructively rotate the contents of the clipboard.\n"
              + "Angles are provided in degrees and a positive angle will result in a clockwise rotation. "
              + "Multiple rotations can be stacked. Interpolation is not performed so angles should be a multiple of 90 degrees.\n")
  @CommandPermissions("worldedit.clipboard.rotate")
  public void rotate(
      Player player,
      LocalSession session,
      Double yRotate,
      @Optional Double xRotate,
      @Optional Double zRotate)
      throws WorldEditException {
    if ((yRotate != null && Math.abs(yRotate % 90) > 0.001)
        || xRotate != null && Math.abs(xRotate % 90) > 0.001
        || zRotate != null && Math.abs(zRotate % 90) > 0.001) {
      player.printDebug(
          "Note: Interpolation is not yet supported, so angles that are multiples of 90 is recommended.");
    }

    ClipboardHolder holder = session.getClipboard();
    AffineTransform transform = new AffineTransform();
    transform = transform.rotateY(-(yRotate != null ? yRotate : 0));
    transform = transform.rotateX(-(xRotate != null ? xRotate : 0));
    transform = transform.rotateZ(-(zRotate != null ? zRotate : 0));
    holder.setTransform(holder.getTransform().combine(transform));
    player.print("The clipboard copy has been rotated.");
  }
コード例 #4
0
  @Command(
      aliases = {"cylinder", "cyl", "c"},
      usage = "<block> [radius] [height]",
      flags = "h",
      desc = "Choose the cylinder brush",
      help = "Chooses the cylinder brush.\n" + "The -h flag creates hollow cylinders instead.",
      min = 1,
      max = 3)
  @CommandPermissions("worldedit.brush.cylinder")
  public void cylinderBrush(
      Player player,
      LocalSession session,
      EditSession editSession,
      Pattern fill,
      @Optional("2") double radius,
      @Optional("1") int height,
      @Switch('h') boolean hollow)
      throws WorldEditException {
    worldEdit.checkMaxBrushRadius(radius);
    worldEdit.checkMaxBrushRadius(height);

    BrushTool tool = session.getBrushTool(player.getItemInHand());
    tool.setFill(fill);
    tool.setSize(radius);

    if (hollow) {
      tool.setBrush(new HollowCylinderBrush(height), "worldedit.brush.cylinder");
    } else {
      tool.setBrush(new CylinderBrush(height), "worldedit.brush.cylinder");
    }

    player.print(String.format("Cylinder brush shape equipped (%.0f by %d).", radius, height));
  }
コード例 #5
0
  @Command(
      aliases = {"smooth"},
      usage = "[size] [iterations]",
      flags = "n",
      desc = "Choose the terrain softener brush",
      help =
          "Chooses the terrain softener brush.\n"
              + "The -n flag makes it only consider naturally occurring blocks.",
      min = 0,
      max = 2)
  @CommandPermissions("worldedit.brush.smooth")
  public void smoothBrush(
      Player player,
      LocalSession session,
      EditSession editSession,
      @Optional("2") double radius,
      @Optional("4") int iterations,
      @Switch('n') boolean naturalBlocksOnly)
      throws WorldEditException {

    worldEdit.checkMaxBrushRadius(radius);

    BrushTool tool = session.getBrushTool(player.getItemInHand());
    tool.setSize(radius);
    tool.setBrush(new SmoothBrush(iterations, naturalBlocksOnly), "worldedit.brush.smooth");

    player.print(
        String.format(
            "Smooth brush equipped (%.0f x %dx, using "
                + (naturalBlocksOnly ? "natural blocks only" : "any block")
                + ").",
            radius,
            iterations));
  }
コード例 #6
0
  @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);
  }
コード例 #7
0
  @Command(
      aliases = {"/deform"},
      usage = "<expression>",
      desc = "Deforms a selected region with an expression",
      help =
          "Deforms a selected region with an expression\n"
              + "The expression is executed for each block and is expected\n"
              + "to modify the variables x, y and z to point to a new block\n"
              + "to fetch. See also tinyurl.com/wesyntax.",
      flags = "ro",
      min = 1,
      max = -1)
  @CommandPermissions("worldedit.region.deform")
  @Logging(ALL)
  public void deform(
      Player player,
      LocalSession session,
      EditSession editSession,
      @Selection Region region,
      @Text String expression,
      @Switch('r') boolean useRawCoords,
      @Switch('o') boolean offset)
      throws WorldEditException {
    final Vector zero;
    Vector unit;

    if (useRawCoords) {
      zero = Vector.ZERO;
      unit = Vector.ONE;
    } else if (offset) {
      zero = session.getPlacementPosition(player);
      unit = Vector.ONE;
    } else {
      final Vector min = region.getMinimumPoint();
      final Vector max = region.getMaximumPoint();

      zero = max.add(min).multiply(0.5);
      unit = max.subtract(zero);

      if (unit.getX() == 0) unit = unit.setX(1.0);
      if (unit.getY() == 0) unit = unit.setY(1.0);
      if (unit.getZ() == 0) unit = unit.setZ(1.0);
    }

    try {
      final int affected = editSession.deformRegion(region, zero, unit, expression);
      player.findFreePosition();
      BBC.VISITOR_BLOCK.send(player, affected);
    } catch (ExpressionException e) {
      player.printError(e.getMessage());
    }
  }
コード例 #8
0
 @Command(
     aliases = {"/regen"},
     usage = "",
     desc = "Regenerates the contents of the selection",
     help =
         "Regenerates the contents of the current selection.\n"
             + "This command might affect things outside the selection,\n"
             + "if they are within the same chunk.",
     min = 0,
     max = 0)
 @CommandPermissions("worldedit.regen")
 @Logging(REGION)
 public void regenerateChunk(
     Player player, LocalSession session, EditSession editSession, @Selection Region region)
     throws WorldEditException {
   Mask mask = session.getMask();
   Mask sourceMask = session.getSourceMask();
   try {
     session.setMask((Mask) null);
     session.setSourceMask((Mask) null);
     player.getWorld().regenerate(region, editSession);
   } finally {
     session.setMask(mask);
     session.setSourceMask(mask);
   }
   BBC.COMMAND_REGEN.send(player);
 }
コード例 #9
0
  @Command(
      aliases = {"/line"},
      usage = "<block> [thickness]",
      desc = "Draws a line segment between cuboid selection corners",
      help =
          "Draws a line segment between cuboid selection corners.\n"
              + "Can only be used with cuboid selections.\n"
              + "Flags:\n"
              + "  -h generates only a shell",
      flags = "h",
      min = 1,
      max = 2)
  @CommandPermissions("worldedit.region.line")
  @Logging(REGION)
  public void line(
      Player player,
      EditSession editSession,
      @Selection Region region,
      Pattern pattern,
      @Optional("0") @Range(min = 0) int thickness,
      @Switch('h') boolean shell)
      throws WorldEditException {

    if (!(region instanceof CuboidRegion)) {
      player.printError("//line only works with cuboid selections");
      return;
    }

    CuboidRegion cuboidregion = (CuboidRegion) region;
    Vector pos1 = cuboidregion.getPos1();
    Vector pos2 = cuboidregion.getPos2();
    int blocksChanged = editSession.drawLine(Patterns.wrap(pattern), pos1, pos2, thickness, !shell);

    BBC.VISITOR_BLOCK.send(player, blocksChanged);
  }
コード例 #10
0
  @Command(
      aliases = {"/curve"},
      usage = "<block> [thickness]",
      desc = "Draws a spline through selected points",
      help =
          "Draws a spline through selected points.\n"
              + "Can only be used with convex polyhedral selections.\n"
              + "Flags:\n"
              + "  -h generates only a shell",
      flags = "h",
      min = 1,
      max = 2)
  @CommandPermissions("worldedit.region.curve")
  @Logging(REGION)
  public void curve(
      Player player,
      EditSession editSession,
      @Selection Region region,
      Pattern pattern,
      @Optional("0") @Range(min = 0) int thickness,
      @Switch('h') boolean shell)
      throws WorldEditException {
    if (!(region instanceof ConvexPolyhedralRegion)) {
      player.printError("//curve only works with convex polyhedral selections");
      return;
    }

    ConvexPolyhedralRegion cpregion = (ConvexPolyhedralRegion) region;
    List<Vector> vectors = new ArrayList<Vector>(cpregion.getVertices());

    int blocksChanged =
        editSession.drawSpline(Patterns.wrap(pattern), vectors, 0, 0, 0, 10, thickness, !shell);

    BBC.VISITOR_BLOCK.send(player, blocksChanged);
  }
コード例 #11
0
  @Command(
      aliases = {"sphere", "s"},
      usage = "<pattern> [radius]",
      flags = "h",
      desc = "Choose the sphere brush",
      help = "Chooses the sphere brush.\n" + "The -h flag creates hollow spheres instead.",
      min = 1,
      max = 2)
  @CommandPermissions("worldedit.brush.sphere")
  public void sphereBrush(
      Player player,
      LocalSession session,
      EditSession editSession,
      Pattern fill,
      @Optional("2") double radius,
      @Switch('h') boolean hollow)
      throws WorldEditException {
    player.print(ChatColor.RED + "Spheres have been disabled in the WorldEdit configuration.");

    //        worldEdit.checkMaxBrushRadius(radius);
    //
    //        BrushTool tool = session.getBrushTool(player.getItemInHand());
    //        tool.setFill(fill);
    //        tool.setSize(radius);
    //
    //        if (hollow) {
    //            tool.setBrush(new HollowSphereBrush(), "worldedit.brush.sphere");
    //        } else {
    //            tool.setBrush(new SphereBrush(), "worldedit.brush.sphere");
    //        }
    //
    //        player.print(String.format("Sphere brush shape equipped (%.0f).", radius));
  }
コード例 #12
0
  @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.");
  }
コード例 #13
0
  @Command(
      aliases = {"butcher", "kill"},
      usage = "[radius]",
      flags = "plangbtfr",
      desc = "Butcher brush",
      help =
          "Kills nearby mobs within the specified radius.\n"
              + "Flags:\n"
              + "  -p also kills pets.\n"
              + "  -n also kills NPCs.\n"
              + "  -g also kills Golems.\n"
              + "  -a also kills animals.\n"
              + "  -b also kills ambient mobs.\n"
              + "  -t also kills mobs with name tags.\n"
              + "  -f compounds all previous flags.\n"
              + "  -r also destroys armor stands.\n"
              + "  -l currently does nothing.",
      min = 0,
      max = 1)
  @CommandPermissions("worldedit.brush.butcher")
  public void butcherBrush(
      Player player, LocalSession session, EditSession editSession, CommandContext args)
      throws WorldEditException {
    LocalConfiguration config = worldEdit.getConfiguration();

    double radius = args.argsLength() > 0 ? args.getDouble(0) : 5;
    double maxRadius = config.maxBrushRadius;
    // hmmmm not horribly worried about this because -1 is still rather efficient,
    // the problem arises when butcherMaxRadius is some really high number but not infinite
    // - original idea taken from https://github.com/sk89q/worldedit/pull/198#issuecomment-6463108
    if (player.hasPermission("worldedit.butcher")) {
      maxRadius = Math.max(config.maxBrushRadius, config.butcherMaxRadius);
    }
    if (radius > maxRadius) {
      player.printError("Maximum allowed brush radius: " + maxRadius);
      return;
    }

    CreatureButcher flags = new CreatureButcher(player);
    flags.fromCommand(args);

    BrushTool tool = session.getBrushTool(player.getItemInHand());
    tool.setSize(radius);
    tool.setBrush(new ButcherBrush(flags), "worldedit.brush.butcher");

    player.print(String.format("Butcher brush equipped (%.0f).", radius));
  }
コード例 #14
0
  @Command(
      aliases = {"/stack"},
      usage = "[count] [direction]",
      flags = "sa",
      desc = "Repeat the contents of the selection",
      help =
          "Repeats the contents of the selection.\n"
              + "Flags:\n"
              + "  -s shifts the selection to the last stacked copy\n"
              + "  -a skips air blocks",
      min = 0,
      max = 2)
  @CommandPermissions("worldedit.region.stack")
  @Logging(ORIENTATION_REGION)
  public void stack(
      Player player,
      EditSession editSession,
      LocalSession session,
      @Selection Region region,
      @Optional("1") @Range(min = 1) int count,
      @Optional(Direction.AIM) @Direction Vector direction,
      @Switch('s') boolean moveSelection,
      @Switch('a') boolean ignoreAirBlocks)
      throws WorldEditException {
    int affected = editSession.stackCuboidRegion(region, direction, count, !ignoreAirBlocks);

    if (moveSelection) {
      try {
        final Vector size = region.getMaximumPoint().subtract(region.getMinimumPoint());

        final Vector shiftVector = direction.multiply(count * (Math.abs(direction.dot(size)) + 1));
        region.shift(shiftVector);

        session.getRegionSelector(player.getWorld()).learnChanges();
        session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
      } catch (RegionOperationException e) {
        player.printError(e.getMessage());
      }
    }

    BBC.VISITOR_BLOCK.send(player, affected);
  }
コード例 #15
0
 @Command(
     aliases = {"clearclipboard"},
     usage = "",
     desc = "Clear your clipboard",
     min = 0,
     max = 0)
 @CommandPermissions("worldedit.clipboard.clear")
 public void clearClipboard(Player player, LocalSession session, EditSession editSession)
     throws WorldEditException {
   session.setClipboard(null);
   player.print("Clipboard cleared.");
 }
コード例 #16
0
  @Command(
      aliases = {"ex", "extinguish"},
      usage = "[radius]",
      desc = "Shortcut fire extinguisher brush",
      min = 0,
      max = 1)
  @CommandPermissions("worldedit.brush.ex")
  public void extinguishBrush(
      Player player, LocalSession session, EditSession editSession, @Optional("5") double radius)
      throws WorldEditException {
    worldEdit.checkMaxBrushRadius(radius);

    BrushTool tool = session.getBrushTool(player.getItemInHand());
    Pattern fill = new BlockPattern(new BaseBlock(0));
    tool.setFill(fill);
    tool.setSize(radius);
    tool.setMask(new BlockMask(editSession, new BaseBlock(BlockID.FIRE)));
    tool.setBrush(new SphereBrush(), "worldedit.brush.ex");

    player.print(String.format("Extinguisher equipped (%.0f).", radius));
  }
コード例 #17
0
  @Command(
      aliases = {"/move"},
      usage = "[count] [direction] [leave-id]",
      flags = "s",
      desc = "Move the contents of the selection",
      help =
          "Moves the contents of the selection.\n"
              + "The -s flag shifts the selection to the target location.\n"
              + "Optionally fills the old location with <leave-id>.",
      min = 0,
      max = 3)
  @CommandPermissions("worldedit.region.move")
  @Logging(ORIENTATION_REGION)
  public void move(
      Player player,
      EditSession editSession,
      LocalSession session,
      @Selection Region region,
      @Optional("1") @Range(min = 1) int count,
      @Optional(Direction.AIM) @Direction Vector direction,
      @Optional("air") BaseBlock replace,
      @Switch('s') boolean moveSelection)
      throws WorldEditException {

    int affected = editSession.moveRegion(region, direction, count, true, replace);

    if (moveSelection) {
      try {
        region.shift(direction.multiply(count));

        session.getRegionSelector(player.getWorld()).learnChanges();
        session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
      } catch (RegionOperationException e) {
        player.printError(e.getMessage());
      }
    }

    BBC.VISITOR_BLOCK.send(player, affected);
  }
コード例 #18
0
 @Command(
     aliases = {"/flip"},
     usage = "[<direction>]",
     desc = "Flip the contents of the clipboard",
     help = "Flips the contents of the clipboard across the point from which the copy was made.\n",
     min = 0,
     max = 1)
 @CommandPermissions("worldedit.clipboard.flip")
 public void flip(
     Player player,
     LocalSession session,
     EditSession editSession,
     @Optional(Direction.AIM) @Direction Vector direction)
     throws WorldEditException {
   ClipboardHolder holder = session.getClipboard();
   Clipboard clipboard = holder.getClipboard();
   AffineTransform transform = new AffineTransform();
   transform = transform.scale(direction.positive().multiply(-2).add(1, 1, 1));
   holder.setTransform(holder.getTransform().combine(transform));
   player.print("The clipboard copy has been flipped.");
 }