mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 09:47:38 +00:00
Added -m for //cut and //copy to set a source mask.
This commit is contained in:
parent
b2e953a95f
commit
d3aa6c86a8
@ -33,6 +33,7 @@ import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
|||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import com.sk89q.worldedit.function.block.BlockReplace;
|
import com.sk89q.worldedit.function.block.BlockReplace;
|
||||||
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
|
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
|
||||||
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
|
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
|
||||||
import com.sk89q.worldedit.function.operation.Operations;
|
import com.sk89q.worldedit.function.operation.Operations;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
@ -69,22 +70,27 @@ public class ClipboardCommands {
|
|||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "/copy" },
|
aliases = { "/copy" },
|
||||||
flags = "e",
|
flags = "em",
|
||||||
desc = "Copy the selection to the clipboard",
|
desc = "Copy the selection to the clipboard",
|
||||||
help = "Copy the selection to the clipboard\n" +
|
help = "Copy the selection to the clipboard\n" +
|
||||||
"Flags:\n" +
|
"Flags:\n" +
|
||||||
" -e controls whether entities are copied\n" +
|
" -e controls whether entities are copied\n" +
|
||||||
|
" -m sets a source mask so that excluded blocks become air\n" +
|
||||||
"WARNING: Pasting entities cannot yet be undone!",
|
"WARNING: Pasting entities cannot yet be undone!",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.clipboard.copy")
|
@CommandPermissions("worldedit.clipboard.copy")
|
||||||
public void copy(Player player, LocalSession session, EditSession editSession,
|
public void copy(Player player, LocalSession session, EditSession editSession,
|
||||||
@Selection Region region, @Switch('e') boolean copyEntities) throws WorldEditException {
|
@Selection Region region, @Switch('e') boolean copyEntities,
|
||||||
|
@Switch('m') Mask mask) throws WorldEditException {
|
||||||
|
|
||||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(region);
|
BlockArrayClipboard clipboard = new BlockArrayClipboard(region);
|
||||||
clipboard.setOrigin(session.getPlacementPosition(player));
|
clipboard.setOrigin(session.getPlacementPosition(player));
|
||||||
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
|
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
|
||||||
|
if (mask != null) {
|
||||||
|
copy.setSourceMask(mask);
|
||||||
|
}
|
||||||
Operations.completeLegacy(copy);
|
Operations.completeLegacy(copy);
|
||||||
session.replaceClipboard(clipboard);
|
session.replaceClipboard(clipboard);
|
||||||
|
|
||||||
@ -93,25 +99,30 @@ public class ClipboardCommands {
|
|||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "/cut" },
|
aliases = { "/cut" },
|
||||||
|
flags = "em",
|
||||||
usage = "[leave-id]",
|
usage = "[leave-id]",
|
||||||
desc = "Cut the selection to the clipboard",
|
desc = "Cut the selection to the clipboard",
|
||||||
help = "Copy the selection to the clipboard\n" +
|
help = "Copy the selection to the clipboard\n" +
|
||||||
"Flags:\n" +
|
"Flags:\n" +
|
||||||
" -e controls whether entities are copied\n" +
|
" -e controls whether entities are copied\n" +
|
||||||
|
" -m sets a source mask so that excluded blocks become air\n" +
|
||||||
"WARNING: Cutting and pasting entities cannot yet be undone!",
|
"WARNING: Cutting and pasting entities cannot yet be undone!",
|
||||||
flags = "e",
|
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.clipboard.cut")
|
@CommandPermissions("worldedit.clipboard.cut")
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
public void cut(Player player, LocalSession session, EditSession editSession,
|
public void cut(Player player, LocalSession session, EditSession editSession,
|
||||||
@Selection Region region, @Optional("air") Pattern leavePattern, @Switch('e') boolean copyEntities) throws WorldEditException {
|
@Selection Region region, @Optional("air") Pattern leavePattern, @Switch('e') boolean copyEntities,
|
||||||
|
@Switch('m') Mask mask) throws WorldEditException {
|
||||||
|
|
||||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(region);
|
BlockArrayClipboard clipboard = new BlockArrayClipboard(region);
|
||||||
clipboard.setOrigin(session.getPlacementPosition(player));
|
clipboard.setOrigin(session.getPlacementPosition(player));
|
||||||
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
|
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
|
||||||
copy.setSourceFunction(new BlockReplace(editSession, leavePattern));
|
copy.setSourceFunction(new BlockReplace(editSession, leavePattern));
|
||||||
|
if (mask != null) {
|
||||||
|
copy.setSourceMask(mask);
|
||||||
|
}
|
||||||
Operations.completeLegacy(copy);
|
Operations.completeLegacy(copy);
|
||||||
session.replaceClipboard(clipboard);
|
session.replaceClipboard(clipboard);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user