コード例 #1
0
ファイル: TreePlanter.java プロジェクト: nsordk/worldedit
  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;
  }
コード例 #2
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.");
      }
    }
  }
コード例 #3
0
 @Command(
     aliases = {"descend"},
     usage = "[# of floors]",
     desc = "Go down a floor",
     min = 0,
     max = 1)
 @CommandPermissions({"worldedit.navigation.descend"})
 public static void descend(
     CommandContext args,
     WorldEdit we,
     LocalSession session,
     LocalPlayer player,
     EditSession editSession)
     throws WorldEditException {
   int levelsToDescend = 0;
   if (args.argsLength() == 0) {
     levelsToDescend = 1;
   } else {
     levelsToDescend = args.getInteger(0);
   }
   int descentLevels = 1;
   while (player.descendLevel() && levelsToDescend != descentLevels) {
     ++descentLevels;
   }
   if (descentLevels == 0) {
     player.printError("No free spot above you found.");
   } else {
     player.print(
         (descentLevels != 1)
             ? "Descended " + Integer.toString(descentLevels) + " levels."
             : "Descended a level.");
   }
 }
コード例 #4
0
  @Command(
      aliases = {"forestgen"},
      usage = "[size] [type] [density]",
      desc = "Generate a forest",
      min = 0,
      max = 3)
  @CommandPermissions({"worldedit.generation.forest"})
  @Logging(POSITION)
  public static void forestGen(
      CommandContext args,
      WorldEdit we,
      LocalSession session,
      LocalPlayer player,
      EditSession editSession)
      throws WorldEditException {

    int size = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 10;
    TreeGenerator.TreeType type =
        args.argsLength() > 1
            ? type = TreeGenerator.lookup(args.getString(1))
            : TreeGenerator.TreeType.TREE;
    double density = args.argsLength() > 2 ? args.getDouble(2) / 100 : 0.05;

    if (type == null) {
      player.printError("Tree type '" + args.getString(1) + "' is unknown.");
      return;
    } else {
    }

    int affected =
        editSession.makeForest(player.getPosition(), size, density, new TreeGenerator(type));
    player.print(affected + " trees created.");
  }
コード例 #5
0
 @Command(
     aliases = {"/save"},
     usage = "<filename>",
     desc = "Сохраняет буфер обмена в схематический файл.",
     min = 0,
     max = 1)
 @Deprecated
 @CommandPermissions("worldedit.clipboard.save")
 public void save(
     CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession)
     throws WorldEditException {
   player.printError("Эта команда больше не используется. Пишите //schematic save.");
 }
コード例 #6
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.");
  }
コード例 #7
0
ファイル: Teleporter.java プロジェクト: balr0g/craftbook
  @Override
  public void onRightClick(PlayerInteractEvent event) {

    if (!plugin.getLocalConfiguration().teleporterSettings.enable) return;

    if (!BukkitUtil.toWorldVector(event.getClickedBlock())
        .equals(BukkitUtil.toWorldVector(trigger))) return; // wth? our manager is insane. ikr.

    LocalPlayer localPlayer = plugin.wrap(event.getPlayer());

    if (!localPlayer.hasPermission("craftbook.mech.teleporter.use")) {
      localPlayer.printError("mech.use-permission");
      return;
    }

    makeItSo(event.getPlayer());

    event.setCancelled(true);
  }
コード例 #8
0
  @Command(
      aliases = {"/stack"},
      usage = "[count] [direction]",
      flags = "sa",
      desc = "Repeat the contents of the selection",
      min = 0,
      max = 2)
  @CommandPermissions("worldedit.region.stack")
  @Logging(ORIENTATION_REGION)
  public static void stack(
      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.getDiagonalDirection(
            player, args.argsLength() > 1 ? args.getString(1).toLowerCase() : "me");

    int affected =
        editSession.stackCuboidRegion(
            session.getSelection(player.getWorld()), dir, count, !args.hasFlag('a'));

    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 changed. Undo with //undo");
  }
コード例 #9
0
  @Override
  public boolean act(
      ServerInterface server,
      LocalConfiguration config,
      LocalPlayer player,
      LocalSession session,
      WorldVector clicked) {

    LocalWorld world = clicked.getWorld();
    EditSession editSession = new EditSession(server, world, session.getBlockChangeLimit());

    try {
      editSession.makePineTree(clicked.add(0, 1, 0));
    } catch (MaxChangedBlocksException e) {
      player.printError("Max blocks change limit reached.");
    } finally {
      session.remember(editSession);
    }

    return true;
  }
コード例 #10
0
  @Command(
      aliases = {"thru"},
      usage = "",
      desc = "Passthrough walls",
      min = 0,
      max = 0)
  @CommandPermissions({"worldedit.navigation.thru"})
  public static void thru(
      CommandContext args,
      WorldEdit we,
      LocalSession session,
      LocalPlayer player,
      EditSession editSession)
      throws WorldEditException {

    if (player.passThroughForwardWall(6)) {
      player.print("Whoosh!");
    } else {
      player.printError("No free spot ahead of you found.");
    }
  }
コード例 #11
0
  @Command(
      aliases = {"/rotate"},
      usage = "<angle-in-degrees>",
      desc = "Поворот содержимого буфера обмена",
      min = 1,
      max = 1)
  @CommandPermissions("worldedit.clipboard.rotate")
  public void rotate(
      CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession)
      throws WorldEditException {

    int angle = args.getInteger(0);

    if (angle % 90 == 0) {
      CuboidClipboard clipboard = session.getClipboard();
      clipboard.rotate2D(angle);
      player.print("Содержимое буфера обмена повернуто на " + angle + " градусов.");
    } else {
      player.printError("Углы должны делиться на 90 градусов.");
    }
  }
コード例 #12
0
  @Command(
      aliases = {"jumpto"},
      usage = "",
      desc = "Teleport to a location",
      min = 0,
      max = 0)
  @CommandPermissions({"worldedit.navigation.jumpto"})
  public static void jumpTo(
      CommandContext args,
      WorldEdit we,
      LocalSession session,
      LocalPlayer player,
      EditSession editSession)
      throws WorldEditException {

    WorldVector pos = player.getSolidBlockTrace(300);
    if (pos != null) {
      player.findFreePosition(pos);
      player.print("Poof!");
    } else {
      player.printError("No block in sight!");
    }
  }
コード例 #13
0
  @Command(
      aliases = {"up"},
      usage = "<block>",
      desc = "Go upwards some distance",
      min = 1,
      max = 1)
  @CommandPermissions({"worldedit.navigation.up"})
  @Logging(POSITION)
  public static void up(
      CommandContext args,
      WorldEdit we,
      LocalSession session,
      LocalPlayer player,
      EditSession editSession)
      throws WorldEditException {

    int distance = args.getInteger(0);

    if (player.ascendUpwards(distance)) {
      player.print("Whoosh!");
    } else {
      player.printError("You would hit something above you.");
    }
  }
コード例 #14
0
  @Command(
      aliases = {"ceil"},
      usage = "[clearance]",
      desc = "Go to the celing",
      min = 0,
      max = 1)
  @CommandPermissions({"worldedit.navigation.ceiling"})
  @Logging(POSITION)
  public static void ceiling(
      CommandContext args,
      WorldEdit we,
      LocalSession session,
      LocalPlayer player,
      EditSession editSession)
      throws WorldEditException {

    int clearence = args.argsLength() > 0 ? Math.max(0, args.getInteger(0)) : 0;

    if (player.ascendToCeiling(clearence)) {
      player.print("Whoosh!");
    } else {
      player.printError("No free spot above you found.");
    }
  }