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;
|
|
|
|
|
2019-07-06 00:46:48 +00:00
|
|
|
import static com.sk89q.worldedit.command.util.Logging.LogMode.POSITION;
|
|
|
|
import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION;
|
|
|
|
|
2018-08-12 14:03:07 +00:00
|
|
|
import com.boydti.fawe.config.BBC;
|
|
|
|
import com.boydti.fawe.object.clipboard.URIClipboardHolder;
|
|
|
|
import com.boydti.fawe.object.mask.IdMask;
|
|
|
|
import com.boydti.fawe.object.regions.selector.FuzzyRegionSelector;
|
|
|
|
import com.boydti.fawe.object.regions.selector.PolyhedralRegionSelector;
|
2019-07-22 02:49:08 +00:00
|
|
|
import com.boydti.fawe.util.ExtentTraverser;
|
2014-04-03 02:08:50 +00:00
|
|
|
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;
|
2019-07-06 00:46:48 +00:00
|
|
|
import com.sk89q.worldedit.command.argument.SelectorChoice;
|
2019-07-25 18:44:10 +00:00
|
|
|
import com.sk89q.worldedit.command.tool.NavigationWand;
|
|
|
|
import com.sk89q.worldedit.command.tool.SelectionWand;
|
2019-07-06 00:46:48 +00:00
|
|
|
import com.sk89q.worldedit.command.util.CommandPermissions;
|
|
|
|
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
|
|
|
import com.sk89q.worldedit.command.util.Logging;
|
2014-06-30 00:47:08 +00:00
|
|
|
import com.sk89q.worldedit.entity.Player;
|
2019-08-06 15:29:49 +00:00
|
|
|
import com.sk89q.worldedit.extension.platform.Actor;
|
|
|
|
import com.sk89q.worldedit.extension.platform.Locatable;
|
2014-07-29 02:50:01 +00:00
|
|
|
import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits;
|
2018-08-12 14:03:07 +00:00
|
|
|
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
2014-06-30 00:47:08 +00:00
|
|
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
2018-08-12 14:03:07 +00:00
|
|
|
import com.sk89q.worldedit.function.mask.Mask;
|
2019-07-06 00:46:48 +00:00
|
|
|
import com.sk89q.worldedit.internal.annotation.Direction;
|
|
|
|
import com.sk89q.worldedit.internal.annotation.MultiDirection;
|
2018-12-23 16:19:33 +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;
|
2019-08-06 15:29:49 +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-07-06 00:46:48 +00:00
|
|
|
import com.sk89q.worldedit.util.formatting.component.SubtleFormat;
|
|
|
|
import com.sk89q.worldedit.util.formatting.component.TextComponentProducer;
|
|
|
|
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
|
|
|
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
|
|
|
|
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
2014-06-30 00:47:08 +00:00
|
|
|
import com.sk89q.worldedit.world.World;
|
2019-07-25 18:44:10 +00:00
|
|
|
import com.sk89q.worldedit.world.item.ItemType;
|
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;
|
2018-08-12 14:03:07 +00:00
|
|
|
import java.io.File;
|
|
|
|
import java.net.URI;
|
2014-06-30 00:47:08 +00:00
|
|
|
import java.util.List;
|
2018-06-16 06:36:55 +00:00
|
|
|
import java.util.Optional;
|
2019-07-06 00:46:48 +00:00
|
|
|
import java.util.stream.Stream;
|
|
|
|
import org.enginehub.piston.annotation.Command;
|
|
|
|
import org.enginehub.piston.annotation.CommandContainer;
|
|
|
|
import org.enginehub.piston.annotation.param.Arg;
|
|
|
|
import org.enginehub.piston.annotation.param.Switch;
|
2018-08-12 14:03:07 +00:00
|
|
|
|
2014-04-03 02:08:50 +00:00
|
|
|
/**
|
|
|
|
* Selection commands.
|
|
|
|
*/
|
2019-07-06 00:46:48 +00:00
|
|
|
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
2014-04-03 02:08:50 +00:00
|
|
|
public class SelectionCommands {
|
2014-07-29 18:04:04 +00:00
|
|
|
|
2014-04-03 02:08:50 +00:00
|
|
|
private final WorldEdit we;
|
2018-08-12 14:03:07 +00:00
|
|
|
|
2014-04-03 02:08:50 +00:00
|
|
|
public SelectionCommands(WorldEdit we) {
|
|
|
|
this.we = we;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-07-06 00:46:48 +00:00
|
|
|
name = "/pos1",
|
|
|
|
desc = "Set position 1"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@Logging(POSITION)
|
|
|
|
@CommandPermissions("worldedit.selection.pos")
|
2019-08-06 15:29:49 +00:00
|
|
|
public void pos1(Actor actor, World world, LocalSession session,
|
2019-07-06 00:46:48 +00:00
|
|
|
@Arg(desc = "Coordinates to set position 1 to", def = "")
|
|
|
|
BlockVector3 coordinates) throws WorldEditException {
|
2019-08-06 15:29:49 +00:00
|
|
|
Location pos;
|
2019-07-06 00:46:48 +00:00
|
|
|
if (coordinates != null) {
|
2019-08-06 15:29:49 +00:00
|
|
|
pos = new Location(world, coordinates.toVector3());
|
|
|
|
} else if (actor instanceof Locatable) {
|
|
|
|
pos = ((Locatable) actor).getBlockLocation();
|
2014-04-03 02:08:50 +00:00
|
|
|
} else {
|
2019-08-06 15:29:49 +00:00
|
|
|
actor.printError("You must provide coordinates as console.");
|
|
|
|
return;
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
2019-08-06 15:29:49 +00:00
|
|
|
|
|
|
|
if (!session.getRegionSelector(world).selectPrimary(pos.toBlockPoint(), ActorSelectorLimits.forActor(actor))) {
|
|
|
|
BBC.SELECTOR_ALREADY_SET.send(actor);
|
2014-04-03 02:08:50 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-08-06 15:29:49 +00:00
|
|
|
session.getRegionSelector(world)
|
|
|
|
.explainPrimarySelection(actor, session, pos.toBlockPoint());
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-07-06 00:46:48 +00:00
|
|
|
name = "/pos2",
|
|
|
|
desc = "Set position 2"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@Logging(POSITION)
|
|
|
|
@CommandPermissions("worldedit.selection.pos")
|
2019-08-06 15:29:49 +00:00
|
|
|
public void pos2(Actor actor, World world, LocalSession session,
|
2019-07-06 00:46:48 +00:00
|
|
|
@Arg(desc = "Coordinates to set position 2 to", def = "")
|
|
|
|
BlockVector3 coordinates) throws WorldEditException {
|
2019-08-06 15:29:49 +00:00
|
|
|
Location pos;
|
2019-07-06 00:46:48 +00:00
|
|
|
if (coordinates != null) {
|
2019-08-06 15:29:49 +00:00
|
|
|
pos = new Location(world, coordinates.toVector3());
|
|
|
|
} else if (actor instanceof Locatable) {
|
|
|
|
pos = ((Locatable) actor).getBlockLocation();
|
2014-04-03 02:08:50 +00:00
|
|
|
} else {
|
2019-08-06 15:29:49 +00:00
|
|
|
actor.printError("You must provide coordinates as console.");
|
|
|
|
return;
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
2019-09-14 03:17:40 +00:00
|
|
|
|
2019-08-06 15:29:49 +00:00
|
|
|
if (!session.getRegionSelector(world).selectSecondary(pos.toBlockPoint(), ActorSelectorLimits.forActor(actor))) {
|
|
|
|
BBC.SELECTOR_ALREADY_SET.send(actor);
|
2014-04-03 02:08:50 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-08-06 15:29:49 +00:00
|
|
|
session.getRegionSelector(world)
|
|
|
|
.explainSecondarySelection(actor, session, pos.toBlockPoint());
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-07-06 00:46:48 +00:00
|
|
|
name = "/hpos1",
|
|
|
|
desc = "Set position 1 to targeted block"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.selection.hpos")
|
2019-07-06 00:46:48 +00:00
|
|
|
public void hpos1(Player player, LocalSession session) throws WorldEditException {
|
|
|
|
|
2019-09-14 03:17:40 +00:00
|
|
|
Location pos = player.getBlockTrace(300);
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
if (pos != null) {
|
2019-09-14 03:17:40 +00:00
|
|
|
if (!session.getRegionSelector(player.getWorld()).selectPrimary(pos.toBlockPoint(), ActorSelectorLimits.forActor(player))) {
|
2018-08-12 14:03:07 +00:00
|
|
|
BBC.SELECTOR_ALREADY_SET.send(player);
|
2014-04-03 02:08:50 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
session.getRegionSelector(player.getWorld())
|
2019-09-14 03:17:40 +00:00
|
|
|
.explainPrimarySelection(player, session, pos.toBlockPoint());
|
2014-04-03 02:08:50 +00:00
|
|
|
} else {
|
2019-04-06 23:13:23 +00:00
|
|
|
BBC.NO_BLOCK.send(player);
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-07-06 00:46:48 +00:00
|
|
|
name = "/hpos2",
|
|
|
|
desc = "Set position 2 to targeted block"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.selection.hpos")
|
2019-07-06 00:46:48 +00:00
|
|
|
public void hpos2(Player player, LocalSession session) throws WorldEditException {
|
|
|
|
|
2019-09-14 03:17:40 +00:00
|
|
|
Location pos = player.getBlockTrace(300);
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
if (pos != null) {
|
2019-09-14 03:17:40 +00:00
|
|
|
if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos.toBlockPoint(), ActorSelectorLimits.forActor(player))) {
|
2018-08-12 14:03:07 +00:00
|
|
|
BBC.SELECTOR_ALREADY_SET.send(player);
|
2014-04-03 02:08:50 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
session.getRegionSelector(player.getWorld())
|
2019-09-14 03:17:40 +00:00
|
|
|
.explainSecondarySelection(player, session, pos.toBlockPoint());
|
2014-04-03 02:08:50 +00:00
|
|
|
} else {
|
2019-04-06 23:13:23 +00:00
|
|
|
BBC.NO_BLOCK.send(player);
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-07-06 00:46:48 +00:00
|
|
|
name = "/chunk",
|
|
|
|
desc = "Set the selection to your current chunk."
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@Logging(POSITION)
|
|
|
|
@CommandPermissions("worldedit.selection.chunk")
|
2019-07-06 00:46:48 +00:00
|
|
|
public void chunk(Player player, LocalSession session,
|
|
|
|
@Arg(desc = "The chunk to select", def = "")
|
|
|
|
BlockVector2 coordinates,
|
|
|
|
@Switch(name = 's', desc = "Expand your selection to encompass all chunks that are part of it")
|
|
|
|
boolean expandSelection,
|
|
|
|
@Switch(name = 'c', desc = "Use chunk coordinates instead of block coordinates")
|
|
|
|
boolean useChunkCoordinates) throws WorldEditException {
|
2018-12-23 16:19:33 +00:00
|
|
|
final BlockVector3 min;
|
|
|
|
final BlockVector3 max;
|
2014-04-05 09:59:38 +00:00
|
|
|
final World world = player.getWorld();
|
2019-07-06 00:46:48 +00:00
|
|
|
if (expandSelection) {
|
2014-04-03 02:08:50 +00:00
|
|
|
Region region = session.getSelection(world);
|
|
|
|
|
2018-12-23 16:19:33 +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
|
|
|
|
2018-08-12 14:03:07 +00:00
|
|
|
BBC.SELECTION_CHUNKS.send(player, min2D.getBlockX() + ", " + min2D.getBlockZ(), max2D.getBlockX() + ", " + max2D.getBlockZ());
|
2014-04-03 02:08:50 +00:00
|
|
|
} else {
|
2018-12-23 16:19:33 +00:00
|
|
|
final BlockVector2 min2D;
|
2019-07-06 00:46:48 +00:00
|
|
|
if (coordinates != null) {
|
2014-04-03 02:08:50 +00:00
|
|
|
// coords specified
|
2019-07-06 00:46:48 +00:00
|
|
|
min2D = useChunkCoordinates
|
|
|
|
? coordinates
|
|
|
|
: ChunkStore.toChunk(coordinates.toBlockVector3());
|
2014-04-03 02:08:50 +00:00
|
|
|
} else {
|
|
|
|
// use player loc
|
2019-08-06 15:29:49 +00:00
|
|
|
min2D = ChunkStore.toChunk(player.getBlockLocation().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);
|
|
|
|
|
2018-08-12 14:03:07 +00:00
|
|
|
BBC.SELECTION_CHUNK.send(player, min2D.getBlockX() + ", " + min2D.getBlockZ());
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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(
|
2019-07-06 00:46:48 +00:00
|
|
|
name = "/wand",
|
|
|
|
desc = "Get the wand object"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.wand")
|
2019-07-06 00:46:48 +00:00
|
|
|
public void wand(Player player, LocalSession session,
|
2019-09-14 03:17:40 +00:00
|
|
|
@Switch(name = 'n', desc = "Get a navigation wand") boolean navWand) throws WorldEditException {
|
2019-07-25 18:44:10 +00:00
|
|
|
String wandId = navWand ? session.getNavWandItem() : session.getWandItem();
|
|
|
|
if (wandId == null) {
|
|
|
|
wandId = navWand ? we.getConfiguration().navigationWand : we.getConfiguration().wandItem;
|
|
|
|
}
|
|
|
|
ItemType itemType = ItemTypes.parse(wandId);
|
|
|
|
if (itemType == null) {
|
|
|
|
player.printError("Wand item is mis-configured or disabled.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
player.giveItem(new BaseItemStack(itemType, 1));
|
|
|
|
if (navWand) {
|
|
|
|
session.setTool(itemType, new NavigationWand());
|
|
|
|
player.print("Left click: jump to location; Right click: pass through walls");
|
|
|
|
} else {
|
|
|
|
session.setTool(itemType, new SelectionWand());
|
2019-10-07 19:09:52 +00:00
|
|
|
player.print(BBC.SELECTION_WAND.s());
|
2019-07-25 18:44:10 +00:00
|
|
|
}
|
2019-06-23 18:00:22 +00:00
|
|
|
if (!player.hasPermission("fawe.tips"))
|
2018-08-15 14:31:44 +00:00
|
|
|
BBC.TIP_SEL_LIST.or(BBC.TIP_SELECT_CONNECTED, BBC.TIP_SET_POS1, BBC.TIP_FARWAND, BBC.TIP_DISCORD).send(player);
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-07-06 00:46:48 +00:00
|
|
|
name = "toggleeditwand",
|
|
|
|
desc = "Remind the user that the wand is now a tool and can be unbound with /none."
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.wand.toggle")
|
2019-07-06 00:46:48 +00:00
|
|
|
public void toggleWand(Player player) {
|
|
|
|
player.print(TextComponent.of("The selection wand is now a normal tool. You can disable it with ")
|
|
|
|
.append(TextComponent.of("/none", TextColor.AQUA).clickEvent(
|
|
|
|
ClickEvent.of(ClickEvent.Action.RUN_COMMAND, "/none")))
|
|
|
|
.append(TextComponent.of(" and rebind it to any item with "))
|
|
|
|
.append(TextComponent.of("//selwand", TextColor.AQUA).clickEvent(
|
|
|
|
ClickEvent.of(ClickEvent.Action.RUN_COMMAND, "//selwand")))
|
|
|
|
.append(TextComponent.of(" or get a new wand with "))
|
|
|
|
.append(TextComponent.of("//wand", TextColor.AQUA).clickEvent(
|
|
|
|
ClickEvent.of(ClickEvent.Action.RUN_COMMAND, "//wand"))));
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-07-06 00:46:48 +00:00
|
|
|
name = "/contract",
|
|
|
|
desc = "Contract the selection area"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@Logging(REGION)
|
|
|
|
@CommandPermissions("worldedit.selection.contract")
|
2019-08-06 15:29:49 +00:00
|
|
|
public void contract(Actor actor, World world, LocalSession session,
|
2019-07-06 00:46:48 +00:00
|
|
|
@Arg(desc = "Amount to contract the selection by")
|
|
|
|
int amount,
|
|
|
|
@Arg(desc = "Amount to contract the selection by in the other direction", def = "0")
|
|
|
|
int reverseAmount,
|
|
|
|
@Arg(desc = "Direction to contract", def = Direction.AIM)
|
|
|
|
@MultiDirection
|
|
|
|
List<BlockVector3> direction) throws WorldEditException {
|
2014-04-03 02:08:50 +00:00
|
|
|
try {
|
2019-08-06 15:29:49 +00:00
|
|
|
Region region = session.getSelection(world);
|
2014-04-03 02:08:50 +00:00
|
|
|
int oldSize = region.getArea();
|
2019-07-06 00:46:48 +00:00
|
|
|
if (reverseAmount == 0) {
|
|
|
|
for (BlockVector3 dir : direction) {
|
|
|
|
region.contract(dir.multiply(amount));
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
} else {
|
2019-07-06 00:46:48 +00:00
|
|
|
for (BlockVector3 dir : direction) {
|
|
|
|
region.contract(dir.multiply(amount), dir.multiply(-reverseAmount));
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
}
|
2019-08-06 15:29:49 +00:00
|
|
|
session.getRegionSelector(world).learnChanges();
|
2014-04-03 02:08:50 +00:00
|
|
|
int newSize = region.getArea();
|
|
|
|
|
2019-08-06 15:29:49 +00:00
|
|
|
session.getRegionSelector(world).explainRegionAdjust(actor, session);
|
2014-04-03 02:08:50 +00:00
|
|
|
|
2019-07-06 00:46:48 +00:00
|
|
|
|
2019-08-06 15:29:49 +00:00
|
|
|
BBC.SELECTION_CONTRACT.send(actor, (oldSize - newSize));
|
2014-04-03 02:08:50 +00:00
|
|
|
} catch (RegionOperationException e) {
|
2019-08-06 15:29:49 +00:00
|
|
|
actor.printError(e.getMessage());
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-07-06 00:46:48 +00:00
|
|
|
name = "/shift",
|
|
|
|
desc = "Shift the selection area"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@Logging(REGION)
|
|
|
|
@CommandPermissions("worldedit.selection.shift")
|
2019-08-06 15:29:49 +00:00
|
|
|
public void shift(Actor actor, World world, LocalSession session,
|
2019-07-06 00:46:48 +00:00
|
|
|
@Arg(desc = "Amount to shift the selection by")
|
|
|
|
int amount,
|
|
|
|
@Arg(desc = "Direction to contract", def = Direction.AIM)
|
|
|
|
@MultiDirection
|
|
|
|
List<BlockVector3> direction) throws WorldEditException {
|
2014-04-03 02:08:50 +00:00
|
|
|
try {
|
2019-08-06 15:29:49 +00:00
|
|
|
Region region = session.getSelection(world);
|
2014-04-03 02:08:50 +00:00
|
|
|
|
2019-07-06 00:46:48 +00:00
|
|
|
for (BlockVector3 dir : direction) {
|
|
|
|
region.shift(dir.multiply(amount));
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
2019-08-06 15:29:49 +00:00
|
|
|
session.getRegionSelector(world).learnChanges();
|
2014-04-03 02:08:50 +00:00
|
|
|
|
2019-08-06 15:29:49 +00:00
|
|
|
session.getRegionSelector(world).explainRegionAdjust(actor, session);
|
2019-07-06 00:46:48 +00:00
|
|
|
|
2019-10-07 19:09:52 +00:00
|
|
|
actor.print(BBC.SELECTION_SHIFT.s());
|
2014-04-03 02:08:50 +00:00
|
|
|
} catch (RegionOperationException e) {
|
2019-08-06 15:29:49 +00:00
|
|
|
actor.printError(e.getMessage());
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-07-06 00:46:48 +00:00
|
|
|
name = "/outset",
|
|
|
|
desc = "Outset the selection area"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@Logging(REGION)
|
|
|
|
@CommandPermissions("worldedit.selection.outset")
|
2019-08-06 15:29:49 +00:00
|
|
|
public void outset(Actor actor, World world, LocalSession session,
|
2019-07-06 00:46:48 +00:00
|
|
|
@Arg(desc = "Amount to expand the selection by in all directions")
|
|
|
|
int amount,
|
|
|
|
@Switch(name = 'h', desc = "Only expand horizontally")
|
|
|
|
boolean onlyHorizontal,
|
|
|
|
@Switch(name = 'v', desc = "Only expand vertically")
|
|
|
|
boolean onlyVertical) throws WorldEditException {
|
2019-08-06 15:29:49 +00:00
|
|
|
Region region = session.getSelection(world);
|
2019-07-06 00:46:48 +00:00
|
|
|
region.expand(getChangesForEachDir(amount, onlyHorizontal, onlyVertical));
|
2019-08-06 15:29:49 +00:00
|
|
|
session.getRegionSelector(world).learnChanges();
|
|
|
|
session.getRegionSelector(world).explainRegionAdjust(actor, session);
|
2019-10-07 19:09:52 +00:00
|
|
|
actor.print(BBC.SELECTION_OUTSET.s());
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-07-06 00:46:48 +00:00
|
|
|
name = "/inset",
|
|
|
|
desc = "Inset the selection area"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@Logging(REGION)
|
|
|
|
@CommandPermissions("worldedit.selection.inset")
|
2019-08-06 15:29:49 +00:00
|
|
|
public void inset(Actor actor, World world, LocalSession session,
|
2019-07-06 00:46:48 +00:00
|
|
|
@Arg(desc = "Amount to contract the selection by in all directions")
|
|
|
|
int amount,
|
|
|
|
@Switch(name = 'h', desc = "Only contract horizontally")
|
|
|
|
boolean onlyHorizontal,
|
|
|
|
@Switch(name = 'v', desc = "Only contract vertically")
|
|
|
|
boolean onlyVertical) throws WorldEditException {
|
2019-08-06 15:29:49 +00:00
|
|
|
Region region = session.getSelection(world);
|
2019-07-06 00:46:48 +00:00
|
|
|
region.contract(getChangesForEachDir(amount, onlyHorizontal, onlyVertical));
|
2019-08-06 15:29:49 +00:00
|
|
|
session.getRegionSelector(world).learnChanges();
|
|
|
|
session.getRegionSelector(world).explainRegionAdjust(actor, session);
|
|
|
|
actor.print("Region inset.");
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
2019-07-06 00:46:48 +00:00
|
|
|
private BlockVector3[] getChangesForEachDir(int amount, boolean onlyHorizontal, boolean onlyVertical) {
|
|
|
|
Stream.Builder<BlockVector3> changes = Stream.builder();
|
2014-04-03 02:08:50 +00:00
|
|
|
|
2019-07-06 00:46:48 +00:00
|
|
|
if (!onlyHorizontal) {
|
|
|
|
changes.add(BlockVector3.UNIT_Y);
|
|
|
|
changes.add(BlockVector3.UNIT_MINUS_Y);
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
2019-07-06 00:46:48 +00:00
|
|
|
if (!onlyVertical) {
|
|
|
|
changes.add(BlockVector3.UNIT_X);
|
|
|
|
changes.add(BlockVector3.UNIT_MINUS_X);
|
|
|
|
changes.add(BlockVector3.UNIT_Z);
|
|
|
|
changes.add(BlockVector3.UNIT_MINUS_Z);
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
2019-07-06 00:46:48 +00:00
|
|
|
return changes.build().map(v -> v.multiply(amount)).toArray(BlockVector3[]::new);
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-07-06 00:46:48 +00:00
|
|
|
name = "/size",
|
|
|
|
desc = "Get information about the selection"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.selection.size")
|
2019-07-06 00:46:48 +00:00
|
|
|
public void size(Player player, LocalSession session,
|
|
|
|
@Switch(name = 'c', desc = "Get clipboard info instead")
|
|
|
|
boolean clipboardInfo) throws WorldEditException {
|
|
|
|
Region region;
|
|
|
|
if (clipboardInfo) {
|
2018-08-12 14:03:07 +00:00
|
|
|
ClipboardHolder root = session.getClipboard();
|
|
|
|
int index = 0;
|
|
|
|
for (ClipboardHolder holder : root.getHolders()) {
|
|
|
|
Clipboard clipboard = holder.getClipboard();
|
|
|
|
String name;
|
|
|
|
if (holder instanceof URIClipboardHolder) {
|
|
|
|
URI uri = ((URIClipboardHolder) holder).getUri();
|
|
|
|
if (uri.toString().startsWith("file:/")) {
|
|
|
|
name = new File(uri.getPath()).getName();
|
|
|
|
} else {
|
|
|
|
name = uri.getFragment();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
name = Integer.toString(index);
|
|
|
|
}
|
|
|
|
|
2019-07-06 00:46:48 +00:00
|
|
|
region = clipboard.getRegion();
|
|
|
|
BlockVector3 size = region.getMaximumPoint()
|
|
|
|
.subtract(region.getMinimumPoint()).
|
|
|
|
add(1, 1, 1);
|
2019-01-09 07:13:44 +00:00
|
|
|
BlockVector3 origin = clipboard.getOrigin();
|
2018-08-12 14:03:07 +00:00
|
|
|
|
|
|
|
String sizeStr = size.getBlockX() + "*" + size.getBlockY() + "*" + size.getBlockZ();
|
|
|
|
String originStr = origin.getBlockX() + "," + origin.getBlockY() + "," + origin.getBlockZ();
|
|
|
|
|
|
|
|
long numBlocks = ((long) size.getBlockX() * size.getBlockY() * size.getBlockZ());
|
|
|
|
|
|
|
|
String msg = String.format("%1$s: %2$s @ %3$s (%4$d blocks)", name, sizeStr, originStr, numBlocks);
|
2019-06-06 01:17:34 +00:00
|
|
|
player.print(msg);
|
2018-08-12 14:03:07 +00:00
|
|
|
|
|
|
|
index++;
|
|
|
|
}
|
2014-04-03 02:08:50 +00:00
|
|
|
return;
|
2019-07-25 18:44:10 +00:00
|
|
|
} else {
|
2018-08-12 14:03:07 +00:00
|
|
|
|
2019-07-25 18:44:10 +00:00
|
|
|
region = session.getSelection(player.getWorld());
|
2019-09-14 03:17:40 +00:00
|
|
|
|
2019-07-25 18:44:10 +00:00
|
|
|
player.print("Type: " + session.getRegionSelector(player.getWorld()).getTypeName());
|
|
|
|
|
2019-09-14 03:17:40 +00:00
|
|
|
for (String line : session.getRegionSelector(player.getWorld()).getInformationLines()) {
|
2019-07-25 18:44:10 +00:00
|
|
|
player.print(line);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2018-12-23 16:19:33 +00:00
|
|
|
BlockVector3 size = region.getMaximumPoint()
|
2014-04-03 02:08:50 +00:00
|
|
|
.subtract(region.getMinimumPoint())
|
|
|
|
.add(1, 1, 1);
|
2018-08-12 14:03:07 +00:00
|
|
|
|
2019-06-06 01:17:34 +00:00
|
|
|
player.print("Size: " + size);
|
|
|
|
player.print("Cuboid distance: " + region.getMaximumPoint().distance(region.getMinimumPoint()));
|
|
|
|
player.print("# of blocks: " + region.getArea());
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Command(
|
2019-07-06 00:46:48 +00:00
|
|
|
name = "/count",
|
2019-07-25 18:44:10 +00:00
|
|
|
desc = "Counts the number of blocks matching a mask"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.analysis.count")
|
2019-07-06 00:46:48 +00:00
|
|
|
public void count(Player player, LocalSession session, EditSession editSession,
|
|
|
|
@Arg(desc = "The mask of blocks to match")
|
|
|
|
Mask mask) throws WorldEditException {
|
2019-07-22 02:49:08 +00:00
|
|
|
int count = editSession.countBlocks(session.getSelection(player.getWorld()), mask);
|
2019-07-17 16:31:13 +00:00
|
|
|
BBC.SELECTION_COUNT.send(player, count);
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-07-06 00:46:48 +00:00
|
|
|
name = "/distr",
|
|
|
|
desc = "Get the distribution of blocks in the selection"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.analysis.distr")
|
2019-07-06 00:46:48 +00:00
|
|
|
public void distr(Player player, LocalSession session, EditSession editSession,
|
|
|
|
@Switch(name = 'c', desc = "Get the distribution of the clipboard instead")
|
|
|
|
boolean clipboardDistr,
|
|
|
|
@Switch(name = 'd', desc = "Separate blocks by state")
|
|
|
|
boolean separateStates) throws WorldEditException {
|
|
|
|
List<Countable> distribution;
|
2018-08-12 14:03:07 +00:00
|
|
|
|
|
|
|
Region region;
|
2019-07-06 00:46:48 +00:00
|
|
|
if (clipboardDistr) {
|
2018-08-12 14:03:07 +00:00
|
|
|
// TODO multi clipboard distribution
|
2019-07-06 00:46:48 +00:00
|
|
|
Clipboard clipboard = session.getClipboard().getClipboard(); // throws if missing
|
2018-08-12 14:03:07 +00:00
|
|
|
region = clipboard.getRegion();
|
2019-07-18 06:56:57 +00:00
|
|
|
new ExtentTraverser<AbstractDelegateExtent>(editSession).setNext(new AbstractDelegateExtent(clipboard));
|
2014-04-03 02:08:50 +00:00
|
|
|
} else {
|
2018-08-12 14:03:07 +00:00
|
|
|
region = session.getSelection(player.getWorld());
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
2019-07-06 00:46:48 +00:00
|
|
|
if (separateStates)
|
|
|
|
distribution = (List) editSession.getBlockDistributionWithData(region);
|
2019-06-12 13:45:41 +00:00
|
|
|
else
|
2019-07-06 00:46:48 +00:00
|
|
|
distribution = (List) editSession.getBlockDistribution(region);
|
2014-04-03 02:08:50 +00:00
|
|
|
|
2019-07-18 06:56:57 +00:00
|
|
|
|
2019-07-06 00:46:48 +00:00
|
|
|
if (distribution.isEmpty()) { // *Should* always be false
|
2019-06-06 01:17:34 +00:00
|
|
|
player.printError("No blocks counted.");
|
2014-04-03 02:08:50 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-07-06 00:46:48 +00:00
|
|
|
|
|
|
|
// note: doing things like region.getArea is inaccurate for non-cuboids.
|
|
|
|
int size = session.getSelection(player.getWorld()).getArea();
|
2018-08-12 14:03:07 +00:00
|
|
|
BBC.SELECTION_DISTR.send(player, size);
|
|
|
|
|
2019-07-06 00:46:48 +00:00
|
|
|
for (Countable c : distribution) {
|
2018-08-12 14:03:07 +00:00
|
|
|
String name = c.getID().toString();
|
|
|
|
String str = String.format("%-7s (%.3f%%) %s",
|
|
|
|
String.valueOf(c.getAmount()),
|
|
|
|
c.getAmount() / (double) size * 100,
|
|
|
|
name);
|
2019-06-06 01:17:34 +00:00
|
|
|
player.print(str);
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-07-06 00:46:48 +00:00
|
|
|
name = "/sel",
|
|
|
|
aliases = { ";", "/desel", "/deselect" },
|
|
|
|
desc = "Choose a region selector"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
2019-09-14 03:17:40 +00:00
|
|
|
public void select(Actor actor, World world, LocalSession session,
|
2019-07-06 00:46:48 +00:00
|
|
|
@Arg(desc = "Selector to switch to", def = "")
|
|
|
|
SelectorChoice selector,
|
2019-08-06 20:18:44 +00:00
|
|
|
@Arg(desc = "Selector mask", def = "") Mask maskOpt,
|
2019-07-06 00:46:48 +00:00
|
|
|
@Switch(name = 'd', desc = "Set default selector")
|
|
|
|
boolean setDefaultSelector) throws WorldEditException {
|
|
|
|
if (selector == null) {
|
2014-04-03 02:08:50 +00:00
|
|
|
session.getRegionSelector(world).clear();
|
2019-08-06 15:29:49 +00:00
|
|
|
session.dispatchCUISelection(actor);
|
2019-10-07 19:09:52 +00:00
|
|
|
actor.print(BBC.SELECTION_CLEARED.s());
|
2014-04-03 02:08:50 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
final RegionSelector oldSelector = session.getRegionSelector(world);
|
|
|
|
|
2019-07-06 00:46:48 +00:00
|
|
|
final RegionSelector newSelector;
|
|
|
|
switch (selector) {
|
|
|
|
case CUBOID:
|
|
|
|
newSelector = new CuboidRegionSelector(oldSelector);
|
2019-08-06 15:29:49 +00:00
|
|
|
actor.print(BBC.SEL_CUBOID.s());
|
2019-07-06 00:46:48 +00:00
|
|
|
break;
|
|
|
|
case EXTEND:
|
|
|
|
newSelector = new ExtendingCuboidRegionSelector(oldSelector);
|
2019-08-06 15:29:49 +00:00
|
|
|
actor.print(BBC.SEL_CUBOID_EXTEND.s());
|
2019-07-06 00:46:48 +00:00
|
|
|
break;
|
|
|
|
case POLY: {
|
|
|
|
newSelector = new Polygonal2DRegionSelector(oldSelector);
|
2019-08-06 15:29:49 +00:00
|
|
|
actor.print(BBC.SEL_2D_POLYGON.s());
|
|
|
|
Optional<Integer> limit = ActorSelectorLimits.forActor(actor).getPolygonVertexLimit();
|
|
|
|
limit.ifPresent(integer -> actor.print(BBC.SEL_MAX.format(integer)));
|
2019-07-06 00:46:48 +00:00
|
|
|
break;
|
2018-08-12 14:03:07 +00:00
|
|
|
}
|
2019-07-06 00:46:48 +00:00
|
|
|
case ELLIPSOID:
|
|
|
|
newSelector = new EllipsoidRegionSelector(oldSelector);
|
2019-08-06 15:29:49 +00:00
|
|
|
actor.print(BBC.SAL_ELLIPSOID.s());
|
2019-07-06 00:46:48 +00:00
|
|
|
break;
|
|
|
|
case SPHERE:
|
|
|
|
newSelector = new SphereRegionSelector(oldSelector);
|
2019-08-06 15:29:49 +00:00
|
|
|
actor.print(BBC.SEL_SPHERE.s());
|
2019-07-06 00:46:48 +00:00
|
|
|
break;
|
|
|
|
case CYL:
|
|
|
|
newSelector = new CylinderRegionSelector(oldSelector);
|
2019-08-06 15:29:49 +00:00
|
|
|
actor.print(BBC.SEL_CYLINDRICAL.s());
|
2019-07-06 00:46:48 +00:00
|
|
|
break;
|
|
|
|
case CONVEX:
|
|
|
|
case HULL:
|
|
|
|
case POLYHEDRON: {
|
|
|
|
newSelector = new ConvexPolyhedralRegionSelector(oldSelector);
|
2019-08-06 15:29:49 +00:00
|
|
|
actor.print(BBC.SEL_CONVEX_POLYHEDRAL.s());
|
|
|
|
Optional<Integer> limit = ActorSelectorLimits.forActor(actor).getPolyhedronVertexLimit();
|
|
|
|
limit.ifPresent(integer -> actor.print(BBC.SEL_MAX.format(integer)));
|
2019-07-06 00:46:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case POLYHEDRAL:
|
2019-08-06 15:29:49 +00:00
|
|
|
newSelector = new PolyhedralRegionSelector(world);
|
|
|
|
actor.print(BBC.SEL_CONVEX_POLYHEDRAL.s());
|
|
|
|
Optional<Integer> limit = ActorSelectorLimits.forActor(actor).getPolyhedronVertexLimit();
|
|
|
|
limit.ifPresent(integer -> actor.print(BBC.SEL_MAX.format(integer)));
|
|
|
|
actor.print(BBC.SEL_LIST.s());
|
2019-07-06 00:46:48 +00:00
|
|
|
break;
|
|
|
|
case FUZZY:
|
|
|
|
case MAGIC:
|
2019-08-06 20:18:44 +00:00
|
|
|
if (maskOpt == null) {
|
|
|
|
maskOpt = new IdMask(world);
|
2019-07-06 00:46:48 +00:00
|
|
|
}
|
2019-08-06 15:29:49 +00:00
|
|
|
//TODO Make FuzzyRegionSelector accept actors
|
2019-08-18 01:09:09 +00:00
|
|
|
newSelector = new FuzzyRegionSelector((Player) actor, world, maskOpt);
|
2019-08-06 15:29:49 +00:00
|
|
|
actor.print(BBC.SEL_FUZZY.s());
|
|
|
|
actor.print(BBC.SEL_LIST.s());
|
2019-07-06 00:46:48 +00:00
|
|
|
break;
|
|
|
|
case LIST:
|
|
|
|
default:
|
2019-09-14 03:17:40 +00:00
|
|
|
CommandListBox box = new CommandListBox("Selection modes", null, null);
|
2019-07-06 00:46:48 +00:00
|
|
|
box.setHidingHelp(true);
|
|
|
|
TextComponentProducer contents = box.getContents();
|
|
|
|
contents.append(SubtleFormat.wrap("Select one of the modes below:")).newline();
|
|
|
|
|
|
|
|
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");
|
|
|
|
box.appendCommand("polyhedral", "Select a hollow polyhedral", "//sel polyhedral");
|
|
|
|
box.appendCommand("fuzzy[=<mask>]", "Select all connected blocks (magic wand)", "//sel fuzzy[=<mask>]");
|
|
|
|
|
2019-08-06 15:29:49 +00:00
|
|
|
actor.print(box.create(1));
|
2019-07-06 00:46:48 +00:00
|
|
|
return;
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
2019-07-06 00:46:48 +00:00
|
|
|
if (setDefaultSelector) {
|
2014-07-29 03:53:17 +00:00
|
|
|
RegionSelectorType found = null;
|
|
|
|
for (RegionSelectorType type : RegionSelectorType.values()) {
|
2019-07-06 00:46:48 +00:00
|
|
|
if (type.getSelectorClass() == newSelector.getClass()) {
|
2014-07-29 03:53:17 +00:00
|
|
|
found = type;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (found != null) {
|
|
|
|
session.setDefaultRegionSelector(found);
|
2019-08-06 15:29:49 +00:00
|
|
|
BBC.SELECTOR_SET_DEFAULT.send(actor, found.name());
|
2014-07-29 03:53:17 +00:00
|
|
|
} else {
|
|
|
|
throw new RuntimeException("Something unexpected happened. Please report this.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-06 00:46:48 +00:00
|
|
|
session.setRegionSelector(world, newSelector);
|
2019-08-06 15:29:49 +00:00
|
|
|
session.dispatchCUISelection(actor);
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
2019-06-06 01:17:34 +00:00
|
|
|
}
|