コード例 #1
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, "блок вырезан", "блока вырезано", "блоков вырезано")
            + ".");
  }
コード例 #2
0
  @Command(
      aliases = {"/removebelow", "removebelow"},
      usage = "[size] [height]",
      desc = "Remove blocks below you.",
      min = 0,
      max = 2)
  @CommandPermissions("worldedit.removebelow")
  @Logging(PLACEMENT)
  public void removeBelow(
      CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession)
      throws WorldEditException {

    int size = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 1;
    we.checkMaxRadius(size);
    LocalWorld world = player.getWorld();
    int height =
        args.argsLength() > 1
            ? Math.min((world.getMaxY() + 1), args.getInteger(1) + 2)
            : (world.getMaxY() + 1);

    int affected = editSession.removeBelow(session.getPlacementPosition(player), size, height);
    player.print(affected + " block(s) have been removed.");
  }
コード例 #3
0
  @Command(
      aliases = {"butcher"},
      usage = "[radius]",
      flags = "plangbf",
      desc = "Kill all or nearby mobs",
      help =
          "Kills nearby mobs, based on radius, if none is given uses default in configuration.\n"
              + "Flags:"
              + "  -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"
              + "  -f compounds all previous flags.\n"
              + "  -l strikes lightning on each killed mob.",
      min = 0,
      max = 1)
  @CommandPermissions("worldedit.butcher")
  @Logging(PLACEMENT)
  @Console
  public void butcher(
      CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession)
      throws WorldEditException {

    LocalConfiguration config = we.getConfiguration();

    // technically the default can be larger than the max, but that's not my problem
    int radius = config.butcherDefaultRadius;

    // there might be a better way to do this but my brain is fried right now
    if (args.argsLength() > 0) { // user inputted radius, override the default
      radius = args.getInteger(0);
      if (config.butcherMaxRadius != -1) { // clamp if there is a max
        if (radius == -1) {
          radius = config.butcherMaxRadius;
        } else { // Math.min does not work if radius is -1 (actually highest possible value)
          radius = Math.min(radius, config.butcherMaxRadius);
        }
      }
    }

    FlagContainer flags = new FlagContainer(player);
    flags.or(KillFlags.FRIENDLY, args.hasFlag('f'));
    flags.or(KillFlags.PETS, args.hasFlag('p'), "worldedit.butcher.pets");
    flags.or(KillFlags.NPCS, args.hasFlag('n'), "worldedit.butcher.npcs");
    flags.or(KillFlags.GOLEMS, args.hasFlag('g'), "worldedit.butcher.golems");
    flags.or(KillFlags.ANIMALS, args.hasFlag('a'), "worldedit.butcher.animals");
    flags.or(KillFlags.AMBIENT, args.hasFlag('b'), "worldedit.butcher.ambient");
    flags.or(KillFlags.WITH_LIGHTNING, args.hasFlag('l'), "worldedit.butcher.lightning");

    int killed;
    if (player.isPlayer()) {
      killed =
          player.getWorld().killMobs(session.getPlacementPosition(player), radius, flags.flags);
    } else {
      killed = 0;
      for (LocalWorld world : we.getServer().getWorlds()) {
        killed += world.killMobs(new Vector(), radius, flags.flags);
      }
    }

    if (radius < 0) {
      player.print("Killed " + killed + " mobs.");
    } else {
      player.print("Killed " + killed + " mobs in a radius of " + radius + ".");
    }
  }