2014-04-03 02:08:50 +00:00
|
|
|
/*
|
2014-04-04 22:03:18 +00:00
|
|
|
* WorldEdit, a Minecraft world manipulation toolkit
|
|
|
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
|
|
|
* Copyright (C) WorldEdit team and contributors
|
2014-04-03 02:08:50 +00:00
|
|
|
*
|
2014-04-04 22:03:18 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU Lesser General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or
|
2014-04-03 02:08:50 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
2014-04-04 22:03:18 +00:00
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
|
|
|
* for more details.
|
2014-04-03 02:08:50 +00:00
|
|
|
*
|
2014-04-04 22:03:18 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
2014-04-03 02:08:50 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2014-04-04 22:03:18 +00:00
|
|
|
*/
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
package com.sk89q.worldedit.command;
|
|
|
|
|
2018-06-16 06:36:55 +00:00
|
|
|
import static com.sk89q.minecraft.util.commands.Logging.LogMode.POSITION;
|
|
|
|
import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
|
|
|
|
|
2014-04-03 02:08:50 +00:00
|
|
|
import com.sk89q.minecraft.util.commands.Command;
|
|
|
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
2014-06-30 00:47:08 +00:00
|
|
|
import com.sk89q.minecraft.util.commands.CommandException;
|
2014-04-03 02:08:50 +00:00
|
|
|
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
|
|
|
import com.sk89q.minecraft.util.commands.Logging;
|
|
|
|
import com.sk89q.worldedit.EditSession;
|
|
|
|
import com.sk89q.worldedit.LocalSession;
|
|
|
|
import com.sk89q.worldedit.WorldEdit;
|
|
|
|
import com.sk89q.worldedit.WorldEditException;
|
2018-06-18 07:53:33 +00:00
|
|
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
2014-06-30 00:47:08 +00:00
|
|
|
import com.sk89q.worldedit.entity.Player;
|
2018-06-17 05:42:47 +00:00
|
|
|
import com.sk89q.worldedit.extension.input.ParserContext;
|
2014-07-29 02:50:01 +00:00
|
|
|
import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits;
|
2014-06-30 00:47:08 +00:00
|
|
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
2019-03-26 02:38:51 +00:00
|
|
|
import com.sk89q.worldedit.function.block.BlockDistributionCounter;
|
|
|
|
import com.sk89q.worldedit.function.operation.Operations;
|
|
|
|
import com.sk89q.worldedit.function.visitor.RegionVisitor;
|
2018-10-14 10:40:53 +00:00
|
|
|
import com.sk89q.worldedit.math.BlockVector2;
|
|
|
|
import com.sk89q.worldedit.math.BlockVector3;
|
2014-06-30 00:47:08 +00:00
|
|
|
import com.sk89q.worldedit.regions.Region;
|
|
|
|
import com.sk89q.worldedit.regions.RegionOperationException;
|
|
|
|
import com.sk89q.worldedit.regions.RegionSelector;
|
2014-04-04 01:32:51 +00:00
|
|
|
import com.sk89q.worldedit.regions.selector.ConvexPolyhedralRegionSelector;
|
|
|
|
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
|
|
|
|
import com.sk89q.worldedit.regions.selector.CylinderRegionSelector;
|
|
|
|
import com.sk89q.worldedit.regions.selector.EllipsoidRegionSelector;
|
|
|
|
import com.sk89q.worldedit.regions.selector.ExtendingCuboidRegionSelector;
|
|
|
|
import com.sk89q.worldedit.regions.selector.Polygonal2DRegionSelector;
|
2014-07-29 03:53:17 +00:00
|
|
|
import com.sk89q.worldedit.regions.selector.RegionSelectorType;
|
2014-04-04 01:32:51 +00:00
|
|
|
import com.sk89q.worldedit.regions.selector.SphereRegionSelector;
|
2014-07-02 09:56:21 +00:00
|
|
|
import com.sk89q.worldedit.session.ClipboardHolder;
|
2014-06-30 00:47:08 +00:00
|
|
|
import com.sk89q.worldedit.util.Countable;
|
2018-06-16 05:29:48 +00:00
|
|
|
import com.sk89q.worldedit.util.Location;
|
2014-07-29 02:56:04 +00:00
|
|
|
import com.sk89q.worldedit.util.formatting.component.CommandListBox;
|
2019-04-19 13:06:00 +00:00
|
|
|
import com.sk89q.worldedit.util.formatting.component.Subtle;
|
2019-04-22 12:05:20 +00:00
|
|
|
import com.sk89q.worldedit.util.formatting.component.TextComponentProducer;
|
2014-06-30 00:47:08 +00:00
|
|
|
import com.sk89q.worldedit.world.World;
|
2018-12-27 00:39:10 +00:00
|
|
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
|
|
|
import com.sk89q.worldedit.world.block.BlockState;
|
2018-07-30 13:26:06 +00:00
|
|
|
import com.sk89q.worldedit.world.item.ItemTypes;
|
2014-06-30 00:47:08 +00:00
|
|
|
import com.sk89q.worldedit.world.storage.ChunkStore;
|
2019-04-21 06:11:39 +00:00
|
|
|
import com.sk89q.worldedit.util.formatting.text.Component;
|
2014-06-30 00:47:08 +00:00
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
2018-06-16 06:36:55 +00:00
|
|
|
import java.util.Optional;
|
2014-06-30 00:47:08 +00:00
|
|
|
import java.util.Set;
|
|
|
|
|
2014-04-03 02:08:50 +00:00
|
|
|
/**
|
|
|
|
* Selection commands.
|
|
|
|
*/
|
|
|
|
public class SelectionCommands {
|
2014-07-29 18:04:04 +00:00
|
|
|
|
2014-04-03 02:08:50 +00:00
|
|
|
private final WorldEdit we;
|
2019-04-21 06:11:39 +00:00
|
|
|
|
2014-04-03 02:08:50 +00:00
|
|
|
public SelectionCommands(WorldEdit we) {
|
|
|
|
this.we = we;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = { "/pos1" },
|
|
|
|
usage = "[coordinates]",
|
|
|
|
desc = "Set position 1",
|
|
|
|
min = 0,
|
|
|
|
max = 1
|
|
|
|
)
|
|
|
|
@Logging(POSITION)
|
|
|
|
@CommandPermissions("worldedit.selection.pos")
|
2019-03-16 23:04:24 +00:00
|
|
|
public void pos1(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
2017-06-09 16:44:54 +00:00
|
|
|
|
2018-06-16 05:29:48 +00:00
|
|
|
Location pos;
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
if (args.argsLength() == 1) {
|
|
|
|
if (args.getString(0).matches("-?\\d+,-?\\d+,-?\\d+")) {
|
|
|
|
String[] coords = args.getString(0).split(",");
|
2018-06-16 05:29:48 +00:00
|
|
|
pos = new Location(player.getWorld(), Integer.parseInt(coords[0]), Integer.parseInt(coords[1]), Integer.parseInt(coords[2]));
|
2014-04-03 02:08:50 +00:00
|
|
|
} else {
|
|
|
|
player.printError("Invalid coordinates " + args.getString(0));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
pos = player.getBlockIn();
|
|
|
|
}
|
|
|
|
|
2018-10-14 10:40:53 +00:00
|
|
|
if (!session.getRegionSelector(player.getWorld()).selectPrimary(pos.toVector().toBlockPoint(), ActorSelectorLimits.forActor(player))) {
|
2014-04-03 02:08:50 +00:00
|
|
|
player.printError("Position already set.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
session.getRegionSelector(player.getWorld())
|
2018-10-14 10:40:53 +00:00
|
|
|
.explainPrimarySelection(player, session, pos.toVector().toBlockPoint());
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = { "/pos2" },
|
|
|
|
usage = "[coordinates]",
|
|
|
|
desc = "Set position 2",
|
|
|
|
min = 0,
|
|
|
|
max = 1
|
|
|
|
)
|
|
|
|
@Logging(POSITION)
|
|
|
|
@CommandPermissions("worldedit.selection.pos")
|
2019-03-16 23:04:24 +00:00
|
|
|
public void pos2(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
2017-06-09 16:44:54 +00:00
|
|
|
|
2018-06-16 05:29:48 +00:00
|
|
|
Location pos;
|
2014-04-03 02:08:50 +00:00
|
|
|
if (args.argsLength() == 1) {
|
|
|
|
if (args.getString(0).matches("-?\\d+,-?\\d+,-?\\d+")) {
|
|
|
|
String[] coords = args.getString(0).split(",");
|
2018-06-16 05:29:48 +00:00
|
|
|
pos = new Location(player.getWorld(), Integer.parseInt(coords[0]),
|
2014-04-03 02:08:50 +00:00
|
|
|
Integer.parseInt(coords[1]),
|
|
|
|
Integer.parseInt(coords[2]));
|
|
|
|
} else {
|
|
|
|
player.printError("Invalid coordinates " + args.getString(0));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
pos = player.getBlockIn();
|
|
|
|
}
|
|
|
|
|
2018-10-14 10:40:53 +00:00
|
|
|
if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos.toVector().toBlockPoint(), ActorSelectorLimits.forActor(player))) {
|
2014-04-03 02:08:50 +00:00
|
|
|
player.printError("Position already set.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
session.getRegionSelector(player.getWorld())
|
2018-10-14 10:40:53 +00:00
|
|
|
.explainSecondarySelection(player, session, pos.toVector().toBlockPoint());
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = { "/hpos1" },
|
|
|
|
usage = "",
|
|
|
|
desc = "Set position 1 to targeted block",
|
|
|
|
min = 0,
|
|
|
|
max = 0
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.selection.hpos")
|
2019-03-16 23:04:24 +00:00
|
|
|
public void hpos1(Player player, LocalSession session) throws WorldEditException {
|
2018-06-16 05:29:48 +00:00
|
|
|
|
|
|
|
Location pos = player.getBlockTrace(300);
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
if (pos != null) {
|
2018-10-14 10:40:53 +00:00
|
|
|
if (!session.getRegionSelector(player.getWorld()).selectPrimary(pos.toVector().toBlockPoint(), ActorSelectorLimits.forActor(player))) {
|
2014-04-03 02:08:50 +00:00
|
|
|
player.printError("Position already set.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
session.getRegionSelector(player.getWorld())
|
2018-10-14 10:40:53 +00:00
|
|
|
.explainPrimarySelection(player, session, pos.toVector().toBlockPoint());
|
2014-04-03 02:08:50 +00:00
|
|
|
} else {
|
|
|
|
player.printError("No block in sight!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = { "/hpos2" },
|
|
|
|
usage = "",
|
|
|
|
desc = "Set position 2 to targeted block",
|
|
|
|
min = 0,
|
|
|
|
max = 0
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.selection.hpos")
|
2019-03-16 23:04:24 +00:00
|
|
|
public void hpos2(Player player, LocalSession session) throws WorldEditException {
|
2018-06-16 05:29:48 +00:00
|
|
|
|
|
|
|
Location pos = player.getBlockTrace(300);
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
if (pos != null) {
|
2018-10-14 10:40:53 +00:00
|
|
|
if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos.toVector().toBlockPoint(), ActorSelectorLimits.forActor(player))) {
|
2014-04-03 02:08:50 +00:00
|
|
|
player.printError("Position already set.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
session.getRegionSelector(player.getWorld())
|
2018-10-14 10:40:53 +00:00
|
|
|
.explainSecondarySelection(player, session, pos.toVector().toBlockPoint());
|
2014-04-03 02:08:50 +00:00
|
|
|
} else {
|
|
|
|
player.printError("No block in sight!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = { "/chunk" },
|
|
|
|
usage = "[x,z coordinates]",
|
|
|
|
flags = "sc",
|
|
|
|
desc = "Set the selection to your current chunk.",
|
|
|
|
help =
|
|
|
|
"Set the selection to the chunk you are currently in.\n" +
|
|
|
|
"With the -s flag, your current selection is expanded\n" +
|
|
|
|
"to encompass all chunks that are part of it.\n\n" +
|
|
|
|
"Specifying coordinates will use those instead of your\n"+
|
|
|
|
"current position. Use -c to specify chunk coordinates,\n" +
|
|
|
|
"otherwise full coordinates will be implied.\n" +
|
|
|
|
"(for example, the coordinates 5,5 are the same as -c 0,0)",
|
|
|
|
min = 0,
|
|
|
|
max = 1
|
|
|
|
)
|
|
|
|
@Logging(POSITION)
|
|
|
|
@CommandPermissions("worldedit.selection.chunk")
|
2019-03-16 23:04:24 +00:00
|
|
|
public void chunk(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
2018-10-14 10:40:53 +00:00
|
|
|
final BlockVector3 min;
|
|
|
|
final BlockVector3 max;
|
2014-04-05 09:59:38 +00:00
|
|
|
final World world = player.getWorld();
|
2014-04-03 02:08:50 +00:00
|
|
|
if (args.hasFlag('s')) {
|
|
|
|
Region region = session.getSelection(world);
|
|
|
|
|
2018-10-14 10:40:53 +00:00
|
|
|
final BlockVector2 min2D = ChunkStore.toChunk(region.getMinimumPoint());
|
|
|
|
final BlockVector2 max2D = ChunkStore.toChunk(region.getMaximumPoint());
|
2014-04-03 02:08:50 +00:00
|
|
|
|
2018-10-19 20:13:32 +00:00
|
|
|
min = BlockVector3.at(min2D.getBlockX() * 16, 0, min2D.getBlockZ() * 16);
|
|
|
|
max = BlockVector3.at(max2D.getBlockX() * 16 + 15, world.getMaxY(), max2D.getBlockZ() * 16 + 15);
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
player.print("Chunks selected: ("
|
|
|
|
+ min2D.getBlockX() + ", " + min2D.getBlockZ() + ") - ("
|
|
|
|
+ max2D.getBlockX() + ", " + max2D.getBlockZ() + ")");
|
|
|
|
} else {
|
2018-10-14 10:40:53 +00:00
|
|
|
final BlockVector2 min2D;
|
2014-04-03 02:08:50 +00:00
|
|
|
if (args.argsLength() == 1) {
|
|
|
|
// coords specified
|
|
|
|
String[] coords = args.getString(0).split(",");
|
|
|
|
if (coords.length != 2) {
|
|
|
|
throw new InsufficientArgumentsException("Invalid coordinates specified.");
|
|
|
|
}
|
|
|
|
int x = Integer.parseInt(coords[0]);
|
|
|
|
int z = Integer.parseInt(coords[1]);
|
2018-10-19 20:13:32 +00:00
|
|
|
BlockVector2 pos = BlockVector2.at(x, z);
|
2018-10-14 10:40:53 +00:00
|
|
|
min2D = (args.hasFlag('c')) ? pos : ChunkStore.toChunk(pos.toBlockVector3());
|
2014-04-03 02:08:50 +00:00
|
|
|
} else {
|
|
|
|
// use player loc
|
2018-10-14 10:40:53 +00:00
|
|
|
min2D = ChunkStore.toChunk(player.getBlockIn().toVector().toBlockPoint());
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
2018-10-19 20:13:32 +00:00
|
|
|
min = BlockVector3.at(min2D.getBlockX() * 16, 0, min2D.getBlockZ() * 16);
|
2014-04-03 02:08:50 +00:00
|
|
|
max = min.add(15, world.getMaxY(), 15);
|
|
|
|
|
|
|
|
player.print("Chunk selected: "
|
|
|
|
+ min2D.getBlockX() + ", " + min2D.getBlockZ());
|
|
|
|
}
|
|
|
|
|
|
|
|
final CuboidRegionSelector selector;
|
|
|
|
if (session.getRegionSelector(world) instanceof ExtendingCuboidRegionSelector) {
|
|
|
|
selector = new ExtendingCuboidRegionSelector(world);
|
|
|
|
} else {
|
|
|
|
selector = new CuboidRegionSelector(world);
|
|
|
|
}
|
2014-07-29 02:50:01 +00:00
|
|
|
selector.selectPrimary(min, ActorSelectorLimits.forActor(player));
|
|
|
|
selector.selectSecondary(max, ActorSelectorLimits.forActor(player));
|
2014-04-03 02:08:50 +00:00
|
|
|
session.setRegionSelector(world, selector);
|
|
|
|
|
|
|
|
session.dispatchCUISelection(player);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = { "/wand" },
|
|
|
|
usage = "",
|
|
|
|
desc = "Get the wand object",
|
|
|
|
min = 0,
|
|
|
|
max = 0
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.wand")
|
2019-03-16 23:04:24 +00:00
|
|
|
public void wand(Player player) throws WorldEditException {
|
2017-06-09 16:44:54 +00:00
|
|
|
|
2018-07-05 08:48:37 +00:00
|
|
|
player.giveItem(new BaseItemStack(ItemTypes.get(we.getConfiguration().wandItem), 1));
|
2014-04-03 02:08:50 +00:00
|
|
|
player.print("Left click: select pos #1; Right click: select pos #2");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = { "toggleeditwand" },
|
|
|
|
usage = "",
|
|
|
|
desc = "Toggle functionality of the edit wand",
|
|
|
|
min = 0,
|
|
|
|
max = 0
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.wand.toggle")
|
2019-03-16 23:04:24 +00:00
|
|
|
public void toggleWand(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
2019-04-21 06:11:39 +00:00
|
|
|
|
2014-04-03 02:08:50 +00:00
|
|
|
session.setToolControl(!session.isToolControlEnabled());
|
|
|
|
|
|
|
|
if (session.isToolControlEnabled()) {
|
|
|
|
player.print("Edit wand enabled.");
|
|
|
|
} else {
|
|
|
|
player.print("Edit wand disabled.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = { "/expand" },
|
|
|
|
usage = "<amount> [reverse-amount] <direction>",
|
|
|
|
desc = "Expand the selection area",
|
|
|
|
min = 1,
|
|
|
|
max = 3
|
|
|
|
)
|
|
|
|
@Logging(REGION)
|
|
|
|
@CommandPermissions("worldedit.selection.expand")
|
2019-03-16 23:04:24 +00:00
|
|
|
public void expand(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
2017-06-09 16:44:54 +00:00
|
|
|
|
2014-04-03 02:08:50 +00:00
|
|
|
// Special syntax (//expand vert) to expand the selection between
|
|
|
|
// sky and bedrock.
|
|
|
|
if (args.getString(0).equalsIgnoreCase("vert")
|
|
|
|
|| args.getString(0).equalsIgnoreCase("vertical")) {
|
|
|
|
Region region = session.getSelection(player.getWorld());
|
|
|
|
try {
|
|
|
|
int oldSize = region.getArea();
|
|
|
|
region.expand(
|
2018-10-19 20:13:32 +00:00
|
|
|
BlockVector3.at(0, (player.getWorld().getMaxY() + 1), 0),
|
|
|
|
BlockVector3.at(0, -(player.getWorld().getMaxY() + 1), 0));
|
2014-04-03 02:08:50 +00:00
|
|
|
session.getRegionSelector(player.getWorld()).learnChanges();
|
|
|
|
int newSize = region.getArea();
|
|
|
|
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
|
|
|
|
player.print("Region expanded " + (newSize - oldSize)
|
|
|
|
+ " blocks [top-to-bottom].");
|
|
|
|
} catch (RegionOperationException e) {
|
|
|
|
player.printError(e.getMessage());
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-10-14 10:40:53 +00:00
|
|
|
List<BlockVector3> dirs = new ArrayList<>();
|
2014-04-03 02:08:50 +00:00
|
|
|
int change = args.getInteger(0);
|
|
|
|
int reverseChange = 0;
|
|
|
|
|
|
|
|
switch (args.argsLength()) {
|
|
|
|
case 2:
|
|
|
|
// Either a reverse amount or a direction
|
|
|
|
try {
|
|
|
|
reverseChange = args.getInteger(1);
|
|
|
|
dirs.add(we.getDirection(player, "me"));
|
|
|
|
} catch (NumberFormatException e) {
|
|
|
|
if (args.getString(1).contains(",")) {
|
|
|
|
String[] split = args.getString(1).split(",");
|
|
|
|
for (String s : split) {
|
|
|
|
dirs.add(we.getDirection(player, s.toLowerCase()));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
dirs.add(we.getDirection(player, args.getString(1).toLowerCase()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
// Both reverse amount and direction
|
|
|
|
reverseChange = args.getInteger(1);
|
|
|
|
if (args.getString(2).contains(",")) {
|
|
|
|
String[] split = args.getString(2).split(",");
|
|
|
|
for (String s : split) {
|
|
|
|
dirs.add(we.getDirection(player, s.toLowerCase()));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
dirs.add(we.getDirection(player, args.getString(2).toLowerCase()));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
dirs.add(we.getDirection(player, "me"));
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Region region = session.getSelection(player.getWorld());
|
|
|
|
int oldSize = region.getArea();
|
|
|
|
|
|
|
|
if (reverseChange == 0) {
|
2018-10-14 10:40:53 +00:00
|
|
|
for (BlockVector3 dir : dirs) {
|
2014-04-03 02:08:50 +00:00
|
|
|
region.expand(dir.multiply(change));
|
|
|
|
}
|
|
|
|
} else {
|
2018-10-14 10:40:53 +00:00
|
|
|
for (BlockVector3 dir : dirs) {
|
2014-04-03 02:08:50 +00:00
|
|
|
region.expand(dir.multiply(change), dir.multiply(-reverseChange));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
session.getRegionSelector(player.getWorld()).learnChanges();
|
|
|
|
int newSize = region.getArea();
|
2019-04-21 06:11:39 +00:00
|
|
|
|
2014-04-03 02:08:50 +00:00
|
|
|
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
|
|
|
|
|
|
|
|
player.print("Region expanded " + (newSize - oldSize) + " blocks.");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = { "/contract" },
|
|
|
|
usage = "<amount> [reverse-amount] [direction]",
|
|
|
|
desc = "Contract the selection area",
|
|
|
|
min = 1,
|
|
|
|
max = 3
|
|
|
|
)
|
|
|
|
@Logging(REGION)
|
|
|
|
@CommandPermissions("worldedit.selection.contract")
|
2019-03-16 23:04:24 +00:00
|
|
|
public void contract(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
2017-06-09 16:44:54 +00:00
|
|
|
|
2018-10-14 10:40:53 +00:00
|
|
|
List<BlockVector3> dirs = new ArrayList<>();
|
2014-04-03 02:08:50 +00:00
|
|
|
int change = args.getInteger(0);
|
|
|
|
int reverseChange = 0;
|
|
|
|
|
|
|
|
switch (args.argsLength()) {
|
|
|
|
case 2:
|
|
|
|
// Either a reverse amount or a direction
|
|
|
|
try {
|
|
|
|
reverseChange = args.getInteger(1);
|
|
|
|
dirs.add(we.getDirection(player, "me"));
|
|
|
|
} catch (NumberFormatException e) {
|
|
|
|
if (args.getString(1).contains(",")) {
|
|
|
|
String[] split = args.getString(1).split(",");
|
|
|
|
for (String s : split) {
|
|
|
|
dirs.add(we.getDirection(player, s.toLowerCase()));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
dirs.add(we.getDirection(player, args.getString(1).toLowerCase()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
// Both reverse amount and direction
|
|
|
|
reverseChange = args.getInteger(1);
|
|
|
|
if (args.getString(2).contains(",")) {
|
|
|
|
String[] split = args.getString(2).split(",");
|
|
|
|
for (String s : split) {
|
|
|
|
dirs.add(we.getDirection(player, s.toLowerCase()));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
dirs.add(we.getDirection(player, args.getString(2).toLowerCase()));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
dirs.add(we.getDirection(player, "me"));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
Region region = session.getSelection(player.getWorld());
|
|
|
|
int oldSize = region.getArea();
|
|
|
|
if (reverseChange == 0) {
|
2018-10-14 10:40:53 +00:00
|
|
|
for (BlockVector3 dir : dirs) {
|
2014-04-03 02:08:50 +00:00
|
|
|
region.contract(dir.multiply(change));
|
|
|
|
}
|
|
|
|
} else {
|
2018-10-14 10:40:53 +00:00
|
|
|
for (BlockVector3 dir : dirs) {
|
2014-04-03 02:08:50 +00:00
|
|
|
region.contract(dir.multiply(change), dir.multiply(-reverseChange));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
session.getRegionSelector(player.getWorld()).learnChanges();
|
|
|
|
int newSize = region.getArea();
|
2019-04-21 06:11:39 +00:00
|
|
|
|
2014-04-03 02:08:50 +00:00
|
|
|
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
|
|
|
|
|
|
|
|
|
|
|
|
player.print("Region contracted " + (oldSize - newSize) + " blocks.");
|
|
|
|
} catch (RegionOperationException e) {
|
|
|
|
player.printError(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = { "/shift" },
|
|
|
|
usage = "<amount> [direction]",
|
|
|
|
desc = "Shift the selection area",
|
|
|
|
min = 1,
|
|
|
|
max = 2
|
|
|
|
)
|
|
|
|
@Logging(REGION)
|
|
|
|
@CommandPermissions("worldedit.selection.shift")
|
2019-03-16 23:04:24 +00:00
|
|
|
public void shift(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
2017-06-09 16:44:54 +00:00
|
|
|
|
2018-10-14 10:40:53 +00:00
|
|
|
List<BlockVector3> dirs = new ArrayList<>();
|
2014-04-03 02:08:50 +00:00
|
|
|
int change = args.getInteger(0);
|
|
|
|
if (args.argsLength() == 2) {
|
|
|
|
if (args.getString(1).contains(",")) {
|
|
|
|
for (String s : args.getString(1).split(",")) {
|
|
|
|
dirs.add(we.getDirection(player, s.toLowerCase()));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
dirs.add(we.getDirection(player, args.getString(1).toLowerCase()));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
dirs.add(we.getDirection(player, "me"));
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
Region region = session.getSelection(player.getWorld());
|
|
|
|
|
2018-10-14 10:40:53 +00:00
|
|
|
for (BlockVector3 dir : dirs) {
|
2014-04-03 02:08:50 +00:00
|
|
|
region.shift(dir.multiply(change));
|
|
|
|
}
|
|
|
|
|
|
|
|
session.getRegionSelector(player.getWorld()).learnChanges();
|
|
|
|
|
|
|
|
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
|
|
|
|
|
|
|
|
player.print("Region shifted.");
|
|
|
|
} catch (RegionOperationException e) {
|
|
|
|
player.printError(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = { "/outset" },
|
|
|
|
usage = "<amount>",
|
|
|
|
desc = "Outset the selection area",
|
|
|
|
help =
|
|
|
|
"Expands the selection by the given amount in all directions.\n" +
|
|
|
|
"Flags:\n" +
|
|
|
|
" -h only expand horizontally\n" +
|
|
|
|
" -v only expand vertically\n",
|
|
|
|
flags = "hv",
|
|
|
|
min = 1,
|
|
|
|
max = 1
|
|
|
|
)
|
|
|
|
@Logging(REGION)
|
|
|
|
@CommandPermissions("worldedit.selection.outset")
|
2019-03-16 23:04:24 +00:00
|
|
|
public void outset(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
2014-04-03 02:08:50 +00:00
|
|
|
Region region = session.getSelection(player.getWorld());
|
|
|
|
region.expand(getChangesForEachDir(args));
|
|
|
|
session.getRegionSelector(player.getWorld()).learnChanges();
|
|
|
|
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
|
|
|
|
player.print("Region outset.");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = { "/inset" },
|
|
|
|
usage = "<amount>",
|
|
|
|
desc = "Inset the selection area",
|
|
|
|
help =
|
|
|
|
"Contracts the selection by the given amount in all directions.\n" +
|
|
|
|
"Flags:\n" +
|
|
|
|
" -h only contract horizontally\n" +
|
|
|
|
" -v only contract vertically\n",
|
|
|
|
flags = "hv",
|
|
|
|
min = 1,
|
|
|
|
max = 1
|
|
|
|
)
|
|
|
|
@Logging(REGION)
|
|
|
|
@CommandPermissions("worldedit.selection.inset")
|
2019-03-16 23:04:24 +00:00
|
|
|
public void inset(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
2014-04-03 02:08:50 +00:00
|
|
|
Region region = session.getSelection(player.getWorld());
|
|
|
|
region.contract(getChangesForEachDir(args));
|
|
|
|
session.getRegionSelector(player.getWorld()).learnChanges();
|
|
|
|
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
|
|
|
|
player.print("Region inset.");
|
|
|
|
}
|
|
|
|
|
2018-10-14 10:40:53 +00:00
|
|
|
private BlockVector3[] getChangesForEachDir(CommandContext args) {
|
|
|
|
List<BlockVector3> changes = new ArrayList<>(6);
|
2014-04-03 02:08:50 +00:00
|
|
|
int change = args.getInteger(0);
|
|
|
|
|
|
|
|
if (!args.hasFlag('h')) {
|
2019-04-04 12:36:19 +00:00
|
|
|
changes.add((BlockVector3.UNIT_Y).multiply(change));
|
|
|
|
changes.add((BlockVector3.UNIT_MINUS_Y).multiply(change));
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!args.hasFlag('v')) {
|
2019-04-04 12:36:19 +00:00
|
|
|
changes.add((BlockVector3.UNIT_X).multiply(change));
|
|
|
|
changes.add((BlockVector3.UNIT_MINUS_X).multiply(change));
|
|
|
|
changes.add((BlockVector3.UNIT_Z).multiply(change));
|
|
|
|
changes.add((BlockVector3.UNIT_MINUS_Z).multiply(change));
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
2018-10-14 10:40:53 +00:00
|
|
|
return changes.toArray(new BlockVector3[0]);
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = { "/size" },
|
|
|
|
flags = "c",
|
|
|
|
usage = "",
|
|
|
|
desc = "Get information about the selection",
|
|
|
|
min = 0,
|
|
|
|
max = 0
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.selection.size")
|
2019-03-16 23:04:24 +00:00
|
|
|
public void size(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
2014-04-03 02:08:50 +00:00
|
|
|
if (args.hasFlag('c')) {
|
2014-07-02 09:56:21 +00:00
|
|
|
ClipboardHolder holder = session.getClipboard();
|
|
|
|
Clipboard clipboard = holder.getClipboard();
|
2014-06-30 00:47:08 +00:00
|
|
|
Region region = clipboard.getRegion();
|
2018-10-14 10:40:53 +00:00
|
|
|
BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint());
|
|
|
|
BlockVector3 origin = clipboard.getOrigin();
|
2014-04-03 02:08:50 +00:00
|
|
|
|
2014-06-30 00:47:08 +00:00
|
|
|
player.print("Cuboid dimensions (max - min): " + size);
|
2014-07-02 09:56:21 +00:00
|
|
|
player.print("Offset: " + origin);
|
2018-10-14 10:40:53 +00:00
|
|
|
player.print("Cuboid distance: " + size.distance(BlockVector3.ONE));
|
2014-06-30 00:47:08 +00:00
|
|
|
player.print("# of blocks: " + (int) (size.getX() * size.getY() * size.getZ()));
|
2014-04-03 02:08:50 +00:00
|
|
|
return;
|
|
|
|
}
|
2018-10-14 10:40:53 +00:00
|
|
|
|
2014-04-03 02:08:50 +00:00
|
|
|
Region region = session.getSelection(player.getWorld());
|
2018-10-14 10:40:53 +00:00
|
|
|
BlockVector3 size = region.getMaximumPoint()
|
2014-04-03 02:08:50 +00:00
|
|
|
.subtract(region.getMinimumPoint())
|
|
|
|
.add(1, 1, 1);
|
2018-10-14 10:40:53 +00:00
|
|
|
|
2014-04-03 02:08:50 +00:00
|
|
|
player.print("Type: " + session.getRegionSelector(player.getWorld())
|
|
|
|
.getTypeName());
|
2018-10-14 10:40:53 +00:00
|
|
|
|
2014-04-03 02:08:50 +00:00
|
|
|
for (String line : session.getRegionSelector(player.getWorld())
|
|
|
|
.getInformationLines()) {
|
|
|
|
player.print(line);
|
|
|
|
}
|
2018-10-14 10:40:53 +00:00
|
|
|
|
2014-04-03 02:08:50 +00:00
|
|
|
player.print("Size: " + size);
|
2014-06-30 00:47:08 +00:00
|
|
|
player.print("Cuboid distance: " + region.getMaximumPoint().distance(region.getMinimumPoint()));
|
2014-04-03 02:08:50 +00:00
|
|
|
player.print("# of blocks: " + region.getArea());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = { "/count" },
|
|
|
|
usage = "<block>",
|
2019-03-26 02:38:51 +00:00
|
|
|
flags = "f",
|
2014-04-03 02:08:50 +00:00
|
|
|
desc = "Counts the number of a certain type of block",
|
|
|
|
min = 1,
|
|
|
|
max = 1
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.analysis.count")
|
2014-06-28 08:01:49 +00:00
|
|
|
public void count(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
2017-06-09 16:44:54 +00:00
|
|
|
|
2018-06-17 05:42:47 +00:00
|
|
|
ParserContext context = new ParserContext();
|
|
|
|
context.setActor(player);
|
|
|
|
context.setExtent(player.getExtent());
|
|
|
|
context.setWorld(player.getWorld());
|
|
|
|
context.setSession(session);
|
|
|
|
context.setRestricted(false);
|
2019-03-26 02:38:51 +00:00
|
|
|
context.setPreferringWildcard(args.hasFlag('f'));
|
2018-06-17 05:42:47 +00:00
|
|
|
|
2018-12-27 00:39:10 +00:00
|
|
|
Set<BaseBlock> searchBlocks = we.getBlockFactory().parseFromListInput(args.getString(0), context);
|
2018-06-17 05:42:47 +00:00
|
|
|
int count = editSession.countBlocks(session.getSelection(player.getWorld()), searchBlocks);
|
|
|
|
player.print("Counted: " + count);
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = { "/distr" },
|
|
|
|
usage = "",
|
|
|
|
desc = "Get the distribution of blocks in the selection",
|
|
|
|
help =
|
|
|
|
"Gets the distribution of blocks in the selection.\n" +
|
|
|
|
"The -c flag gets the distribution of your clipboard.\n" +
|
2018-07-30 13:26:06 +00:00
|
|
|
"The -d flag separates blocks by state",
|
2014-04-03 02:08:50 +00:00
|
|
|
flags = "cd",
|
|
|
|
min = 0,
|
|
|
|
max = 0
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.analysis.distr")
|
2014-06-30 00:47:08 +00:00
|
|
|
public void distr(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException, CommandException {
|
2017-06-09 16:44:54 +00:00
|
|
|
|
2018-12-27 00:39:10 +00:00
|
|
|
boolean separateStates = args.hasFlag('d');
|
|
|
|
List<Countable<BlockState>> distribution;
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
if (args.hasFlag('c')) {
|
2019-03-26 02:38:51 +00:00
|
|
|
Clipboard clipboard = session.getClipboard().getClipboard(); // throws if missing
|
|
|
|
BlockDistributionCounter count = new BlockDistributionCounter(clipboard, separateStates);
|
|
|
|
RegionVisitor visitor = new RegionVisitor(clipboard.getRegion(), count);
|
|
|
|
Operations.completeBlindly(visitor);
|
|
|
|
distribution = count.getDistribution();
|
2014-04-03 02:08:50 +00:00
|
|
|
} else {
|
2018-12-27 00:39:10 +00:00
|
|
|
distribution = editSession.getBlockDistribution(session.getSelection(player.getWorld()), separateStates);
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
2018-08-19 07:53:29 +00:00
|
|
|
if (distribution.isEmpty()) { // *Should* always be false
|
2014-04-03 02:08:50 +00:00
|
|
|
player.printError("No blocks counted.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-03-26 02:38:51 +00:00
|
|
|
// note: doing things like region.getArea is inaccurate for non-cuboids.
|
|
|
|
int size = distribution.stream().mapToInt(Countable::getAmount).sum();
|
2014-04-03 02:08:50 +00:00
|
|
|
player.print("# total blocks: " + size);
|
|
|
|
|
2018-12-27 00:39:10 +00:00
|
|
|
for (Countable<BlockState> c : distribution) {
|
2018-08-19 07:53:29 +00:00
|
|
|
String name = c.getID().getBlockType().getName();
|
|
|
|
String str;
|
2018-12-27 00:39:10 +00:00
|
|
|
if (separateStates) {
|
2019-03-26 02:38:51 +00:00
|
|
|
str = String.format("%-7s (%.3f%%) %s (%s)",
|
2018-07-30 13:26:06 +00:00
|
|
|
String.valueOf(c.getAmount()),
|
|
|
|
c.getAmount() / (double) size * 100,
|
|
|
|
name,
|
2018-08-19 07:53:29 +00:00
|
|
|
c.getID().getAsString());
|
|
|
|
} else {
|
2019-03-26 02:38:51 +00:00
|
|
|
str = String.format("%-7s (%.3f%%) %s (%s)",
|
2018-07-30 13:26:06 +00:00
|
|
|
String.valueOf(c.getAmount()),
|
|
|
|
c.getAmount() / (double) size * 100,
|
|
|
|
name,
|
2018-08-19 07:53:29 +00:00
|
|
|
c.getID().getBlockType().getId());
|
2018-07-30 13:26:06 +00:00
|
|
|
}
|
2018-08-19 07:53:29 +00:00
|
|
|
player.print(str);
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2014-07-07 00:29:17 +00:00
|
|
|
aliases = { "/sel", ";", "/desel", "/deselect" },
|
2014-07-29 03:53:17 +00:00
|
|
|
flags = "d",
|
2014-04-03 02:08:50 +00:00
|
|
|
usage = "[cuboid|extend|poly|ellipsoid|sphere|cyl|convex]",
|
|
|
|
desc = "Choose a region selector",
|
|
|
|
min = 0,
|
|
|
|
max = 1
|
|
|
|
)
|
2019-03-16 23:04:24 +00:00
|
|
|
public void select(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
2014-04-05 09:59:38 +00:00
|
|
|
final World world = player.getWorld();
|
2014-04-03 02:08:50 +00:00
|
|
|
if (args.argsLength() == 0) {
|
|
|
|
session.getRegionSelector(world).clear();
|
|
|
|
session.dispatchCUISelection(player);
|
|
|
|
player.print("Selection cleared.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
final String typeName = args.getString(0);
|
|
|
|
final RegionSelector oldSelector = session.getRegionSelector(world);
|
|
|
|
|
|
|
|
final RegionSelector selector;
|
|
|
|
if (typeName.equalsIgnoreCase("cuboid")) {
|
|
|
|
selector = new CuboidRegionSelector(oldSelector);
|
|
|
|
player.print("Cuboid: left click for point 1, right click for point 2");
|
|
|
|
} else if (typeName.equalsIgnoreCase("extend")) {
|
|
|
|
selector = new ExtendingCuboidRegionSelector(oldSelector);
|
|
|
|
player.print("Cuboid: left click for a starting point, right click to extend");
|
|
|
|
} else if (typeName.equalsIgnoreCase("poly")) {
|
2014-07-29 02:50:01 +00:00
|
|
|
selector = new Polygonal2DRegionSelector(oldSelector);
|
2014-04-03 02:08:50 +00:00
|
|
|
player.print("2D polygon selector: Left/right click to add a point.");
|
2014-07-29 02:50:01 +00:00
|
|
|
Optional<Integer> limit = ActorSelectorLimits.forActor(player).getPolygonVertexLimit();
|
2018-06-16 06:36:55 +00:00
|
|
|
limit.ifPresent(integer -> player.print(integer + " points maximum."));
|
2014-04-03 02:08:50 +00:00
|
|
|
} else if (typeName.equalsIgnoreCase("ellipsoid")) {
|
|
|
|
selector = new EllipsoidRegionSelector(oldSelector);
|
|
|
|
player.print("Ellipsoid selector: left click=center, right click to extend");
|
|
|
|
} else if (typeName.equalsIgnoreCase("sphere")) {
|
|
|
|
selector = new SphereRegionSelector(oldSelector);
|
|
|
|
player.print("Sphere selector: left click=center, right click to set radius");
|
|
|
|
} else if (typeName.equalsIgnoreCase("cyl")) {
|
|
|
|
selector = new CylinderRegionSelector(oldSelector);
|
|
|
|
player.print("Cylindrical selector: Left click=center, right click to extend.");
|
|
|
|
} else if (typeName.equalsIgnoreCase("convex") || typeName.equalsIgnoreCase("hull") || typeName.equalsIgnoreCase("polyhedron")) {
|
2014-07-29 02:50:01 +00:00
|
|
|
selector = new ConvexPolyhedralRegionSelector(oldSelector);
|
2014-04-03 02:08:50 +00:00
|
|
|
player.print("Convex polyhedral selector: Left click=First vertex, right click to add more.");
|
2014-07-29 02:50:01 +00:00
|
|
|
Optional<Integer> limit = ActorSelectorLimits.forActor(player).getPolyhedronVertexLimit();
|
2018-06-16 06:36:55 +00:00
|
|
|
limit.ifPresent(integer -> player.print(integer + " points maximum."));
|
2014-04-03 02:08:50 +00:00
|
|
|
} else {
|
2014-07-29 02:56:04 +00:00
|
|
|
CommandListBox box = new CommandListBox("Selection modes");
|
2019-04-22 12:05:20 +00:00
|
|
|
TextComponentProducer contents = box.getContents();
|
|
|
|
contents.append(new Subtle("Select one of the modes below:").append(Component.newline()).create());
|
|
|
|
|
|
|
|
box.appendCommand("cuboid", "Select two corners of a cuboid", "//sel cuboid");
|
|
|
|
box.appendCommand("extend", "Fast cuboid selection mode", "//sel extend");
|
|
|
|
box.appendCommand("poly", "Select a 2D polygon with height", "//sel poly");
|
|
|
|
box.appendCommand("ellipsoid", "Select an ellipsoid", "//sel ellipsoid");
|
|
|
|
box.appendCommand("sphere", "Select a sphere", "//sel sphere");
|
|
|
|
box.appendCommand("cyl", "Select a cylinder", "//sel cyl");
|
|
|
|
box.appendCommand("convex", "Select a convex polyhedral", "//sel convex");
|
|
|
|
|
|
|
|
player.print(box.create());
|
2014-04-03 02:08:50 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-07-29 03:53:17 +00:00
|
|
|
if (args.hasFlag('d')) {
|
|
|
|
RegionSelectorType found = null;
|
|
|
|
for (RegionSelectorType type : RegionSelectorType.values()) {
|
|
|
|
if (type.getSelectorClass() == selector.getClass()) {
|
|
|
|
found = type;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (found != null) {
|
|
|
|
session.setDefaultRegionSelector(found);
|
|
|
|
player.print("Your default region selector is now " + found.name() + ".");
|
|
|
|
} else {
|
|
|
|
throw new RuntimeException("Something unexpected happened. Please report this.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-03 02:08:50 +00:00
|
|
|
session.setRegionSelector(world, selector);
|
|
|
|
session.dispatchCUISelection(player);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|