Пример #1
0
  @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.");
  }
Пример #2
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.");
  }
Пример #3
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.");
  }
Пример #4
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.");
  }
Пример #5
0
  @Command(
      aliases = {"/overlay"},
      usage = "<block>",
      desc = "Set a block on top of blocks in the region",
      min = 1,
      max = 1)
  @CommandPermissions("worldedit.region.overlay")
  @Logging(REGION)
  public static void overlay(
      CommandContext args,
      WorldEdit we,
      LocalSession session,
      LocalPlayer player,
      EditSession editSession)
      throws WorldEditException {

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

    Region region = session.getSelection(player.getWorld());
    int affected = 0;
    if (pat instanceof SingleBlockPattern) {
      affected = editSession.overlayCuboidBlocks(region, ((SingleBlockPattern) pat).getBlock());
    } else {
      affected = editSession.overlayCuboidBlocks(region, pat);
    }
    player.print(affected + " block(s) have been overlayed.");
  }
  @Command(
      aliases = {"/fillr"},
      usage = "<block> <radius> [depth]",
      desc = "Fill a hole recursively",
      min = 2,
      max = 3)
  @CommandPermissions("worldedit.fill.recursive")
  @Logging(PLACEMENT)
  public void fillr(
      CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession)
      throws WorldEditException {

    Pattern pattern = we.getBlockPattern(player, args.getString(0));
    double radius = Math.max(1, args.getDouble(1));
    we.checkMaxRadius(radius);
    int depth = args.argsLength() > 2 ? Math.max(1, args.getInteger(2)) : 1;

    Vector pos = session.getPlacementPosition(player);
    int affected = 0;
    if (pattern instanceof SingleBlockPattern) {
      affected =
          editSession.fillXZ(pos, ((SingleBlockPattern) pattern).getBlock(), radius, depth, true);
    } else {
      affected = editSession.fillXZ(pos, pattern, radius, depth, true);
    }
    player.print(affected + " block(s) have been created.");
  }
Пример #7
0
  @Command(
      aliases = {"/replace"},
      usage = "[from-block] <to-block>",
      desc = "Replace all blocks in the selection with another",
      flags = "f",
      min = 1,
      max = 2)
  @CommandPermissions("worldedit.region.replace")
  @Logging(REGION)
  public static void replace(
      CommandContext args,
      WorldEdit we,
      LocalSession session,
      LocalPlayer player,
      EditSession editSession)
      throws WorldEditException {

    Set<BaseBlock> from;
    Pattern to;
    if (args.argsLength() == 1) {
      from = null;
      to = we.getBlockPattern(player, args.getString(0));
    } else {
      from = we.getBlocks(player, args.getString(0), true, !args.hasFlag('f'));
      to = we.getBlockPattern(player, args.getString(1));
    }

    int affected = 0;
    if (to instanceof SingleBlockPattern) {
      affected =
          editSession.replaceBlocks(
              session.getSelection(player.getWorld()), from, ((SingleBlockPattern) to).getBlock());
    } else {
      affected = editSession.replaceBlocks(session.getSelection(player.getWorld()), from, to);
    }

    player.print(affected + " block(s) have been replaced.");
  }
  @Command(
      aliases = {"/replacenear", "replacenear"},
      usage = "<size> <from-id> <to-id>",
      desc = "Replace nearby blocks",
      flags = "f",
      min = 3,
      max = 3)
  @CommandPermissions("worldedit.replacenear")
  @Logging(PLACEMENT)
  public void replaceNear(
      CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession)
      throws WorldEditException {

    int size = Math.max(1, args.getInteger(0));
    int affected;
    Set<BaseBlock> from;
    Pattern to;
    if (args.argsLength() == 2) {
      from = null;
      to = we.getBlockPattern(player, args.getString(1));
    } else {
      from = we.getBlocks(player, args.getString(1), true, !args.hasFlag('f'));
      to = we.getBlockPattern(player, args.getString(2));
    }

    Vector base = session.getPlacementPosition(player);
    Vector min = base.subtract(size, size, size);
    Vector max = base.add(size, size, size);
    Region region = new CuboidRegion(player.getWorld(), min, max);

    if (to instanceof SingleBlockPattern) {
      affected = editSession.replaceBlocks(region, from, ((SingleBlockPattern) to).getBlock());
    } else {
      affected = editSession.replaceBlocks(region, from, to);
    }
    player.print(affected + " block(s) have been replaced.");
  }
Пример #9
0
  @Command(
      aliases = {"/cyl"},
      usage = "<block> <radius> [height] ",
      desc = "Generate a cylinder",
      min = 2,
      max = 3)
  @CommandPermissions({"worldedit.generation.cylinder"})
  @Logging(PLACEMENT)
  public static void cyl(
      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));
    int height = args.argsLength() > 2 ? args.getInteger(2) : 1;

    Vector pos = session.getPlacementPosition(player);
    int affected = editSession.makeCylinder(pos, block, radius, height);
    player.print(affected + " block(s) have been created.");
  }