@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"); } }
@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."); }
@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."); }
@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); }
@Command( aliases = {"/flip"}, usage = "[<direction>]", desc = "Flip the contents of the clipboard", help = "Flips the contents of the clipboard across the point from which the copy was made.\n", min = 0, max = 1) @CommandPermissions("worldedit.clipboard.flip") public void flip( Player player, LocalSession session, EditSession editSession, @Optional(Direction.AIM) @Direction Vector direction) throws WorldEditException { ClipboardHolder holder = session.getClipboard(); Clipboard clipboard = holder.getClipboard(); AffineTransform transform = new AffineTransform(); transform = transform.scale(direction.positive().multiply(-2).add(1, 1, 1)); holder.setTransform(holder.getTransform().combine(transform)); player.print("The clipboard copy has been flipped."); }
@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 градусов."); } }
@Command( aliases = {"/flip"}, usage = "[dir]", flags = "p", desc = "Переворачивает содержимое буфера обмена.", help = "Переворачивает содержимое буфера обмена.\n" + "Флаг -p переворачивает выделенную территорию вокруг игрока,\n" + "а не центра выделения.", min = 0, max = 1) @CommandPermissions("worldedit.clipboard.flip") public void flip( CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession) throws WorldEditException { CuboidClipboard.FlipDirection dir = we.getFlipDirection(player, args.argsLength() > 0 ? args.getString(0).toLowerCase() : "me"); CuboidClipboard clipboard = session.getClipboard(); clipboard.flip(dir, args.hasFlag('p')); player.print("Содержимое буфера обмена перевернуто."); }