Ejemplo n.º 1
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);
  }
Ejemplo n.º 2
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);
  }
Ejemplo n.º 3
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());
    }
  }
  @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));
  }
Ejemplo n.º 5
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);
  }
Ejemplo n.º 6
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);
  }