Example #1
0
  @Command(
      aliases = {"/redo", "redo"},
      usage = "[times] [player]",
      desc = "Redoes the last action (from history)",
      min = 0,
      max = 2)
  @CommandPermissions("worldedit.history.redo")
  public void redo(
      CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession)
      throws WorldEditException {

    int times = Math.max(1, args.getInteger(0, 1));

    for (int i = 0; i < times; ++i) {
      EditSession redone;
      if (args.argsLength() < 2) {
        redone = session.redo(session.getBlockBag(player));
      } else {
        player.checkPermission("worldedit.history.redo.other");
        LocalSession sess = we.getSession(args.getString(1));
        if (sess == null) {
          player.printError("Unable to find session for " + args.getString(1));
          break;
        }
        redone = sess.redo(session.getBlockBag(player));
      }
      if (redone != null) {
        player.print("Redo successful.");
        we.flushBlockBag(player, redone);
      } else {
        player.printError("Nothing left to redo.");
      }
    }
  }
Example #2
0
  public boolean actPrimary(
      ServerInterface server,
      LocalConfiguration config,
      LocalPlayer player,
      LocalSession session,
      WorldVector clicked) {

    EditSession editSession = session.createEditSession(player);

    try {
      boolean successful = false;

      for (int i = 0; i < 10; i++) {
        if (gen.generate(editSession, clicked.add(0, 1, 0))) {
          successful = true;
          break;
        }
      }

      if (!successful) {
        player.printError("A tree can't go there.");
      }
    } catch (MaxChangedBlocksException e) {
      player.printError("Max. blocks changed reached.");
    } finally {
      session.remember(editSession);
    }

    return true;
  }
  @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.");
  }
  public void explainSecondarySelection(LocalPlayer player, LocalSession session, Vector pos) {
    player.print("Added point #" + region.size() + " at " + pos + ".");

    session.dispatchCUIEvent(player, new SelectionPoint2DEvent(region.size() - 1, pos, getArea()));
    session.dispatchCUIEvent(
        player, new SelectionMinMaxEvent(region.getMinimumY(), region.getMaximumY()));
  }
Example #5
0
  /**
   * Gets the region selection for the player.
   *
   * @param player
   * @return the selection or null if there was none
   */
  public Selection getSelection(Player player) {
    if (player == null) {
      throw new IllegalArgumentException("Null player not allowed");
    }
    if (!player.isOnline()) {
      throw new IllegalArgumentException("Offline player not allowed");
    }

    LocalSession session = controller.getSession(wrapPlayer(player));
    RegionSelector selector =
        session.getRegionSelector(BukkitUtil.getLocalWorld(player.getWorld()));

    try {
      Region region = selector.getRegion();
      World world = ((BukkitWorld) session.getSelectionWorld()).getWorld();

      if (region instanceof CuboidRegion) {
        return new CuboidSelection(world, selector, (CuboidRegion) region);
      } else if (region instanceof Polygonal2DRegion) {
        return new Polygonal2DSelection(world, selector, (Polygonal2DRegion) region);
      } else {
        return null;
      }
    } catch (IncompleteRegionException e) {
      return null;
    }
  }
  public boolean actPrimary(
      ServerInterface server,
      LocalConfiguration config,
      LocalPlayer player,
      LocalSession session,
      WorldVector clicked) {

    BlockBag bag = session.getBlockBag(player);

    LocalWorld world = clicked.getWorld();
    EditSession editSession =
        WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1, bag, player);

    try {
      editSession.setBlock(clicked, targetBlock);
    } catch (MaxChangedBlocksException e) {
    } finally {
      if (bag != null) {
        bag.flushChanges();
      }
      session.remember(editSession);
    }

    return true;
  }
  @Command(
      aliases = {"/set"},
      usage = "<block>",
      desc = "Set all the blocks inside the selection to a block",
      min = 1,
      max = 1)
  @CommandPermissions("worldedit.region.set")
  @Logging(REGION)
  public static void set(
      CommandContext args,
      WorldEdit we,
      LocalSession session,
      LocalPlayer player,
      EditSession editSession)
      throws WorldEditException {

    Pattern pattern = we.getBlockPattern(player, args.getString(0));

    int affected;

    if (pattern instanceof SingleBlockPattern) {
      affected =
          editSession.setBlocks(
              session.getSelection(player.getWorld()), ((SingleBlockPattern) pattern).getBlock());
    } else {
      affected = editSession.setBlocks(session.getSelection(player.getWorld()), pattern);
    }

    player.print(affected + " block(s) have been changed.");
  }
 @Override
 public void onPluginMessageReceived(String channel, Player player, byte[] message) {
   LocalSession session = plugin.getSession(player);
   String text = new String(message, UTF_8_CHARSET);
   session.handleCUIInitializationMessage(text);
   session.describeCUI(plugin.wrapPlayer(player));
 }
Example #9
0
  @Override
  public boolean importWorldeditSelection() {
    LocalSession worldeditsession =
        getSelection().getPlugin().getWorldEdit().getSession(getPlayer());
    if (worldeditsession == null) {
      return false;
    }

    Region region;
    try {
      region = worldeditsession.getSelection(worldeditsession.getSelectionWorld());
    } catch (IncompleteRegionException e) {
      return false;
    }

    if (!(region instanceof com.sk89q.worldedit.regions.Polygonal2DRegion)) {
      // getPlayer().sendMessage(ChatColor.RED + "Your worldedit selection is invalid type.");
      return false;
    }

    com.sk89q.worldedit.regions.Polygonal2DRegion npolysel =
        (com.sk89q.worldedit.regions.Polygonal2DRegion) region;
    clearPoints();
    for (BlockVector2D vec : npolysel.getPoints()) {
      addPoint(new ZoneVertice(vec.getBlockX(), vec.getBlockZ()));
    }
    setHeight(
        new ZoneVertice(
            npolysel.getMinimumPoint().getBlockY(), npolysel.getMaximumPoint().getBlockY()),
        true);

    return true;
  }
  @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.");
  }
Example #11
0
  @Command(
      aliases = {"/faces", "/outline"},
      usage = "<block>",
      desc = "Build the walls, ceiling, and floor of a selection",
      min = 1,
      max = 1)
  @CommandPermissions("worldedit.region.faces")
  @Logging(REGION)
  public static void faces(
      CommandContext args,
      WorldEdit we,
      LocalSession session,
      LocalPlayer player,
      EditSession editSession)
      throws WorldEditException {

    Pattern pattern = we.getBlockPattern(player, args.getString(0));
    int affected;
    if (pattern instanceof SingleBlockPattern) {
      affected =
          editSession.makeCuboidFaces(
              session.getSelection(player.getWorld()), ((SingleBlockPattern) pattern).getBlock());
    } else {
      affected = editSession.makeCuboidFaces(session.getSelection(player.getWorld()), pattern);
    }

    player.print(affected + " block(s) have been changed.");
  }
Example #12
0
  @Command(
      aliases = {"/copy"},
      flags = "e",
      desc = "Копирует выделенную территорию в буфер обмена",
      help =
          "Копирует выделенную территорию в буфер обмен\n"
              + "Флаги:\n"
              + "  -e определяет, будут ли объекты копироваться в буфер обмена\n"
              + "ПРЕДУПРЕЖДЕНИЕ: Вставленные объекты не могут быть отменены!",
      min = 0,
      max = 0)
  @CommandPermissions("worldedit.clipboard.copy")
  public void copy(
      CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession)
      throws WorldEditException {

    Region region = session.getSelection(player.getWorld());
    Vector min = region.getMinimumPoint();
    Vector max = region.getMaximumPoint();
    Vector pos = session.getPlacementPosition(player);

    CuboidClipboard clipboard =
        new CuboidClipboard(max.subtract(min).add(new Vector(1, 1, 1)), min, min.subtract(pos));
    clipboard.copy(editSession);
    if (args.hasFlag('e')) {
      for (LocalEntity entity : player.getWorld().getEntities(region)) {
        clipboard.storeEntity(entity);
      }
    }
    session.setClipboard(clipboard);

    player.print("Блок(и) скопирован(ы).");
  }
Example #13
0
  @Command(
      aliases = {"/paste"},
      usage = "",
      flags = "ao",
      desc = "Вставляет содержимое буфера обмена",
      help =
          "Вставить содержимое буфера обмена.\n"
              + "Флаги:\n"
              + "  -a пропускает блоки воздуха\n"
              + "  -o вставляет на позициях, которые были скопированы/вырезаны",
      min = 0,
      max = 0)
  @CommandPermissions("worldedit.clipboard.paste")
  @Logging(PLACEMENT)
  public void paste(
      CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession)
      throws WorldEditException {

    boolean atOrigin = args.hasFlag('o');
    boolean pasteNoAir = args.hasFlag('a');

    if (atOrigin) {
      Vector pos = session.getClipboard().getOrigin();
      session.getClipboard().place(editSession, pos, pasteNoAir);
      session.getClipboard().pasteEntities(pos);
      player.findFreePosition();
      player.print("Вставлено. Для отмены напишите //undo");
    } else {
      Vector pos = session.getPlacementPosition(player);
      session.getClipboard().paste(editSession, pos, pasteNoAir, true);
      player.findFreePosition();
      player.print("Вставлено. Для отмены напишите //undo");
    }
  }
  public void explainPrimarySelection(LocalPlayer player, LocalSession session, Vector pos) {
    player.print("Starting a new polygon at " + pos + ".");

    session.dispatchCUIEvent(player, new SelectionShapeEvent(getTypeID()));
    session.dispatchCUIEvent(player, new SelectionPoint2DEvent(0, pos, getArea()));
    session.dispatchCUIEvent(
        player, new SelectionMinMaxEvent(region.getMinimumY(), region.getMaximumY()));
  }
  public void describeCUI(LocalSession session, LocalPlayer player) {
    final List<BlockVector2D> points = region.getPoints();
    for (int id = 0; id < points.size(); id++) {
      session.dispatchCUIEvent(player, new SelectionPoint2DEvent(id, points.get(id), getArea()));
    }

    session.dispatchCUIEvent(
        player, new SelectionMinMaxEvent(region.getMinimumY(), region.getMaximumY()));
  }
  public void explainRegionAdjust(LocalPlayer player, LocalSession session) {
    if (pos1 != null) {
      session.dispatchCUIEvent(player, new SelectionPointEvent(0, pos1, getArea()));
    }

    if (pos2 != null) {
      session.dispatchCUIEvent(player, new SelectionPointEvent(1, pos2, getArea()));
    }
  }
  public void describeCUI(LocalSession session, LocalPlayer player) {
    if (pos1 != null) {
      session.dispatchCUIEvent(player, new SelectionPointEvent(0, pos1, getArea()));
    }

    if (pos2 != null) {
      session.dispatchCUIEvent(player, new SelectionPointEvent(1, pos2, getArea()));
    }
  }
Example #18
0
  /**
   * Remember an edit session.
   *
   * @param player
   * @param editSession
   */
  public void remember(Player player, EditSession editSession) {
    LocalPlayer wePlayer = wrapPlayer(player);
    LocalSession session = controller.getSession(wePlayer);

    session.remember(editSession);
    editSession.flushQueue();

    controller.flushBlockBag(wePlayer, editSession);
  }
  @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);
  }
Example #20
0
  /**
   * Gets the session for the player.
   *
   * @param player
   * @return
   */
  public EditSession createEditSession(Player player) {
    LocalPlayer wePlayer = wrapPlayer(player);
    LocalSession session = controller.getSession(wePlayer);
    BlockBag blockBag = session.getBlockBag(wePlayer);

    EditSession editSession =
        controller
            .getEditSessionFactory()
            .getEditSession(wePlayer.getWorld(), session.getBlockChangeLimit(), blockBag, wePlayer);
    editSession.enableQueue();

    return editSession;
  }
Example #21
0
  @Command(
      aliases = {"/cut"},
      usage = "[leave-id]",
      desc = "Вырезает выделенную территорию в буфер обмена",
      help =
          "Вырезает выделенную территорию в буфер обмена\n"
              + "Флаги:\n"
              + "  -e controls определяет, будут ли объекты копироваться в буфер обмена\n"
              + "ПРЕДУПРЕЖДЕНИЕ: Вырезанные и вставленные объекты не могут быть отменены!",
      flags = "e",
      min = 0,
      max = 1)
  @CommandPermissions("worldedit.clipboard.cut")
  @Logging(REGION)
  public void cut(
      CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession)
      throws WorldEditException {

    BaseBlock block = new BaseBlock(BlockID.AIR);
    LocalWorld world = player.getWorld();

    if (args.argsLength() > 0) {
      block = we.getBlock(player, args.getString(0));
    }

    Region region = session.getSelection(world);
    Vector min = region.getMinimumPoint();
    Vector max = region.getMaximumPoint();
    Vector pos = session.getPlacementPosition(player);

    CuboidClipboard clipboard =
        new CuboidClipboard(max.subtract(min).add(new Vector(1, 1, 1)), min, min.subtract(pos));
    clipboard.copy(editSession);
    if (args.hasFlag('e')) {
      LocalEntity[] entities = world.getEntities(region);
      for (LocalEntity entity : entities) {
        clipboard.storeEntity(entity);
      }
      world.killEntities(entities);
    }
    session.setClipboard(clipboard);

    int affected = editSession.setBlocks(session.getSelection(world), block);
    player.print(
        affected
            + " "
            + StringUtil.plural(affected, "блок вырезан", "блока вырезано", "блоков вырезано")
            + ".");
  }
  @SubscribeEvent
  public void onPacketData(ServerCustomPacketEvent event) {
    if (event.getPacket().channel().equals(ForgeWorldEdit.CUI_PLUGIN_CHANNEL)) {
      EntityPlayerMP player = getPlayerFromEvent(event);
      LocalSession session = ForgeWorldEdit.inst.getSession((EntityPlayerMP) player);

      if (session.hasCUISupport()) {
        return;
      }

      String text = event.getPacket().payload().toString(UTF_8_CHARSET);
      session.handleCUIInitializationMessage(text);
      session.describeCUI(ForgeWorldEdit.inst.wrap(player));
    }
  }
Example #23
0
  @Command(
      aliases = {"/move"},
      usage = "[count] [direction] [leave-id]",
      flags = "s",
      desc = "Move the contents of the selection",
      min = 0,
      max = 3)
  @CommandPermissions("worldedit.region.move")
  @Logging(ORIENTATION_REGION)
  public static void move(
      CommandContext args,
      WorldEdit we,
      LocalSession session,
      LocalPlayer player,
      EditSession editSession)
      throws WorldEditException {

    int count = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 1;
    Vector dir =
        we.getDirection(player, args.argsLength() > 1 ? args.getString(1).toLowerCase() : "me");
    BaseBlock replace;

    // Replacement block argument
    if (args.argsLength() > 2) {
      replace = we.getBlock(player, args.getString(2));
    } else {
      replace = new BaseBlock(BlockID.AIR);
    }

    int affected =
        editSession.moveCuboidRegion(
            session.getSelection(player.getWorld()), dir, count, true, replace);

    if (args.hasFlag('s')) {
      try {
        Region region = session.getSelection(player.getWorld());
        region.expand(dir.multiply(count));
        region.contract(dir.multiply(count));

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

    player.print(affected + " blocks moved.");
  }
  @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.");
  }
Example #25
0
  @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.");
  }
  @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));
  }
  @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));
  }
  @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));
  }
Example #29
0
  @Command(
      aliases = {"/hpyramid"},
      usage = "<block> <range>",
      desc = "Generate a hollow pyramid",
      min = 2,
      max = 2)
  @CommandPermissions({"worldedit.generation.pyramid"})
  @Logging(PLACEMENT)
  public static void hpyramid(
      CommandContext args,
      WorldEdit we,
      LocalSession session,
      LocalPlayer player,
      EditSession editSession)
      throws WorldEditException {

    Pattern block = we.getBlockPattern(player, args.getString(0));
    int size = Math.max(1, args.getInteger(1));
    Vector pos = session.getPlacementPosition(player);

    int affected = editSession.makePyramid(pos, block, size, false);

    player.findFreePosition();
    player.print(affected + " block(s) have been created.");
  }
Example #30
0
  @Command(
      aliases = {"/hsphere"},
      usage = "<block> <radius> [raised?] ",
      desc = "Generate a hollow sphere",
      min = 2,
      max = 3)
  @CommandPermissions({"worldedit.generation.sphere"})
  @Logging(PLACEMENT)
  public static void hsphere(
      CommandContext args,
      WorldEdit we,
      LocalSession session,
      LocalPlayer player,
      EditSession editSession)
      throws WorldEditException {

    Pattern block = we.getBlockPattern(player, args.getString(0));
    double radius = Math.max(1, args.getDouble(1));
    boolean raised =
        args.argsLength() > 2
            ? (args.getString(2).equalsIgnoreCase("true")
                || args.getString(2).equalsIgnoreCase("yes"))
            : false;

    Vector pos = session.getPlacementPosition(player);
    if (raised) {
      pos = pos.add(0, radius, 0);
    }

    int affected = editSession.makeSphere(pos, block, radius, false);
    player.findFreePosition();
    player.print(affected + " block(s) have been created.");
  }