Skip to content
Permalink
Browse files

Add -n flag to //paste to select without pasting.

  • Loading branch information
wizjany committed Nov 9, 2019
1 parent 2b1a7ed commit fc5c625f021232c883c00a52806e5812cbc69a5a
Showing with 22 additions and 14 deletions.
  1. +22 −14 worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java
@@ -140,6 +140,8 @@ public void paste(Actor actor, World world, LocalSession session, EditSession ed
boolean atOrigin,
@Switch(name = 's', desc = "Select the region after pasting")
boolean selectPasted,
@Switch(name = 'n', desc = "No paste, select only. (Implies -s)")
boolean onlySelect,
@Switch(name = 'e', desc = "Paste entities if available")
boolean pasteEntities,
@Switch(name = 'b', desc = "Paste biomes if available")
@@ -151,19 +153,23 @@ public void paste(Actor actor, World world, LocalSession session, EditSession ed
ClipboardHolder holder = session.getClipboard();
Clipboard clipboard = holder.getClipboard();
Region region = clipboard.getRegion();
List<String> messages = Lists.newArrayList();

BlockVector3 to = atOrigin ? clipboard.getOrigin() : session.getPlacementPosition(actor);
Operation operation = holder
.createPaste(editSession)
.to(to)
.ignoreAirBlocks(ignoreAirBlocks)
.copyBiomes(pasteBiomes)
.copyEntities(pasteEntities)
.maskSource(sourceMask)
.build();
Operations.completeLegacy(operation);

if (selectPasted) {
if (!onlySelect) {
Operation operation = holder
.createPaste(editSession)
.to(to)
.ignoreAirBlocks(ignoreAirBlocks)
.copyBiomes(pasteBiomes)
.copyEntities(pasteEntities)
.maskSource(sourceMask)
.build();
Operations.completeLegacy(operation);
operation.addStatusMessages(messages);
}

if (selectPasted || onlySelect) {
BlockVector3 clipboardOffset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
Vector3 realTo = to.toVector3().add(holder.getTransform().apply(clipboardOffset.toVector3()));
Vector3 max = realTo.add(holder.getTransform().apply(region.getMaximumPoint().subtract(region.getMinimumPoint()).toVector3()));
@@ -173,9 +179,11 @@ public void paste(Actor actor, World world, LocalSession session, EditSession ed
selector.explainRegionAdjust(actor, session);
}

actor.print("The clipboard has been pasted at " + to);
List<String> messages = Lists.newArrayList();
operation.addStatusMessages(messages);
if (onlySelect) {
actor.print("Selected clipboard paste region.");
} else {
actor.print("The clipboard has been pasted at " + to);
}
messages.forEach(actor::print);
}

0 comments on commit fc5c625

Please sign in to comment.
You can’t perform that action at this time.