From ab0d170d9a834134e9f7aa449a7ee26c67cd97ba Mon Sep 17 00:00:00 2001 From: wizjany Date: Sun, 12 Jan 2014 14:54:44 -0500 Subject: [PATCH] Added -s flag to //paste to select the pasted area. Also undeprecated a method that shouldn't have been. --- .../com/sk89q/worldedit/blocks/BlockType.java | 2 -- .../worldedit/commands/ClipboardCommands.java | 31 ++++++++++++++----- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/sk89q/worldedit/blocks/BlockType.java b/src/main/java/com/sk89q/worldedit/blocks/BlockType.java index ab1f5b843..5483f2ca6 100644 --- a/src/main/java/com/sk89q/worldedit/blocks/BlockType.java +++ b/src/main/java/com/sk89q/worldedit/blocks/BlockType.java @@ -530,9 +530,7 @@ public enum BlockType { * * @param id * @return - * @deprecated Use {@link #canPassThrough(int,int)} instead */ - @Deprecated public static boolean canPassThrough(int id) { return canPassThrough.contains(id); } diff --git a/src/main/java/com/sk89q/worldedit/commands/ClipboardCommands.java b/src/main/java/com/sk89q/worldedit/commands/ClipboardCommands.java index 5ca1410e6..a38530f3f 100644 --- a/src/main/java/com/sk89q/worldedit/commands/ClipboardCommands.java +++ b/src/main/java/com/sk89q/worldedit/commands/ClipboardCommands.java @@ -30,6 +30,7 @@ import com.sk89q.worldedit.*; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BlockID; import com.sk89q.worldedit.regions.CuboidRegion; +import com.sk89q.worldedit.regions.CuboidRegionSelector; import com.sk89q.worldedit.regions.Region; /** @@ -139,13 +140,14 @@ public class ClipboardCommands { @Command( aliases = { "/paste" }, usage = "", - flags = "ao", + 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", + " -o pastes at the original position\n" + + " -s selects the region after pasting", min = 0, max = 0 ) @@ -157,18 +159,33 @@ public class ClipboardCommands { boolean atOrigin = args.hasFlag('o'); boolean pasteNoAir = args.hasFlag('a'); + CuboidClipboard clipboard = session.getClipboard(); + + Vector pos = atOrigin ? session.getClipboard().getOrigin() + : session.getPlacementPosition(player); + if (atOrigin) { - Vector pos = session.getClipboard().getOrigin(); - session.getClipboard().place(editSession, pos, pasteNoAir); - session.getClipboard().pasteEntities(pos); + clipboard.place(editSession, pos, pasteNoAir); + clipboard.pasteEntities(pos); player.findFreePosition(); player.print("Pasted to copy origin. Undo with //undo"); } else { - Vector pos = session.getPlacementPosition(player); - session.getClipboard().paste(editSession, pos, pasteNoAir, true); + clipboard.paste(editSession, pos, pasteNoAir, true); player.findFreePosition(); player.print("Pasted relative to you. Undo with //undo"); } + + if (args.hasFlag('s')) { + LocalWorld world = player.getWorld(); + Vector pos2 = pos.add(clipboard.getSize().subtract(1, 1, 1)); + if (!atOrigin) { + pos2 = pos2.add(clipboard.getOffset()); + pos = pos.add(clipboard.getOffset()); + } + session.setRegionSelector(world, new CuboidRegionSelector(world, pos, pos2)); + session.getRegionSelector(world).learnChanges(); + session.getRegionSelector(world).explainRegionAdjust(player, session); + } } @Command(