Add -p to /br clipboard to paste using origin of clipboard.

Closes WORLDEDIT-2825.
Dieser Commit ist enthalten in:
sk89q 2014-07-10 01:19:08 -07:00
Ursprung 708b38312c
Commit 4f5e130b59
2 geänderte Dateien mit 10 neuen und 9 gelöschten Zeilen

Datei anzeigen

@ -46,7 +46,6 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.function.mask.BlockMask; import com.sk89q.worldedit.function.mask.BlockMask;
import com.sk89q.worldedit.function.pattern.BlockPattern; import com.sk89q.worldedit.function.pattern.BlockPattern;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.util.command.binding.Switch; import com.sk89q.worldedit.util.command.binding.Switch;
import com.sk89q.worldedit.util.command.parametric.Optional; import com.sk89q.worldedit.util.command.parametric.Optional;
@ -132,16 +131,16 @@ public class BrushCommands {
@Command( @Command(
aliases = { "clipboard", "copy" }, aliases = { "clipboard", "copy" },
usage = "", usage = "",
flags = "a",
desc = "Choose the clipboard brush", desc = "Choose the clipboard brush",
help = help =
"Chooses the clipboard brush.\n" + "Chooses the clipboard brush.\n" +
"The -a flag makes it not paste air.", "The -a flag makes it not paste air.\n" +
min = 0, "Without the -p flag, the paste will appear centered at the target location. " +
max = 0 "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") @CommandPermissions("worldedit.brush.clipboard")
public void clipboardBrush(Player player, LocalSession session, EditSession editSession, @Switch('a') boolean ignoreAir) throws WorldEditException { public void clipboardBrush(Player player, LocalSession session, EditSession editSession, @Switch('a') boolean ignoreAir, @Switch('p') boolean usingOrigin) throws WorldEditException {
ClipboardHolder holder = session.getClipboard(); ClipboardHolder holder = session.getClipboard();
Clipboard clipboard = holder.getClipboard(); Clipboard clipboard = holder.getClipboard();
@ -152,7 +151,7 @@ public class BrushCommands {
worldEdit.checkMaxBrushRadius(size.getBlockZ()); worldEdit.checkMaxBrushRadius(size.getBlockZ());
BrushTool tool = session.getBrushTool(player.getItemInHand()); BrushTool tool = session.getBrushTool(player.getItemInHand());
tool.setBrush(new ClipboardBrush(holder, ignoreAir), "worldedit.brush.clipboard"); tool.setBrush(new ClipboardBrush(holder, ignoreAir, usingOrigin), "worldedit.brush.clipboard");
player.print("Clipboard brush shape equipped."); player.print("Clipboard brush shape equipped.");
} }

Datei anzeigen

@ -33,10 +33,12 @@ public class ClipboardBrush implements Brush {
private ClipboardHolder holder; private ClipboardHolder holder;
private boolean ignoreAirBlocks; private boolean ignoreAirBlocks;
private boolean usingOrigin;
public ClipboardBrush(ClipboardHolder holder, boolean ignoreAirBlocks) { public ClipboardBrush(ClipboardHolder holder, boolean ignoreAirBlocks, boolean usingOrigin) {
this.holder = holder; this.holder = holder;
this.ignoreAirBlocks = ignoreAirBlocks; this.ignoreAirBlocks = ignoreAirBlocks;
this.usingOrigin = usingOrigin;
} }
@Override @Override
@ -47,7 +49,7 @@ public class ClipboardBrush implements Brush {
Operation operation = holder Operation operation = holder
.createPaste(editSession, editSession.getWorld().getWorldData()) .createPaste(editSession, editSession.getWorld().getWorldData())
.to(pos.subtract(centerOffset)) .to(usingOrigin ? pos : pos.subtract(centerOffset))
.ignoreAirBlocks(ignoreAirBlocks) .ignoreAirBlocks(ignoreAirBlocks)
.build(); .build();