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-08-12 14:03:07 +00:00
import com.boydti.fawe.config.BBC ;
import com.boydti.fawe.object.FawePlayer ;
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 ;
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-08-10 10:29:06 +00:00
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 ;
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-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-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-04-03 13:25:16 +00:00
import com.sk89q.worldedit.util.Location ;
2018-08-12 14:03:07 +00:00
import com.sk89q.worldedit.util.command.binding.Switch ;
2014-07-29 02:56:04 +00:00
import com.sk89q.worldedit.util.formatting.ColorCodeBuilder ;
import com.sk89q.worldedit.util.formatting.Style ;
import com.sk89q.worldedit.util.formatting.StyledFragment ;
import com.sk89q.worldedit.util.formatting.component.CommandListBox ;
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 ;
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.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
2018-08-12 14:03:07 +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
/ * *
* Selection commands .
* /
2018-08-12 14:03:07 +00:00
@Command ( aliases = { } , desc = " Change your selection points, mode or view info about your selection: [More Info](http://wiki.sk89q.com/wiki/WorldEdit/Selection) " )
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 (
2018-08-12 14:03:07 +00:00
aliases = { " /pos1 " , " posa " , " /1 " } ,
usage = " [coordinates] " ,
desc = " Set position 1 " ,
min = 0 ,
max = 1
2014-04-03 02:08:50 +00:00
)
@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
2019-04-03 13:25:16 +00:00
BlockVector3 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-10-19 20:13:32 +00:00
pos = BlockVector3 . at ( Integer . parseInt ( coords [ 0 ] ) , Integer . parseInt ( coords [ 1 ] ) , Integer . parseInt ( coords [ 2 ] ) ) ;
2014-04-03 02:08:50 +00:00
} else {
2018-08-12 14:03:07 +00:00
BBC . SELECTOR_INVALID_COORDINATES . send ( player , args . getString ( 0 ) ) ;
2014-04-03 02:08:50 +00:00
return ;
}
} else {
2019-03-31 16:09:20 +00:00
pos = player . getBlockIn ( ) . toBlockPoint ( ) ;
2014-04-03 02:08:50 +00:00
}
2018-08-12 14:03:07 +00:00
pos = pos . clampY ( 0 , player . getWorld ( ) . getMaximumPoint ( ) . getBlockY ( ) ) ;
if ( ! session . getRegionSelector ( player . getWorld ( ) ) . selectPrimary ( pos , ActorSelectorLimits . forActor ( player ) ) ) {
BBC . SELECTOR_ALREADY_SET . send ( player ) ;
2014-04-03 02:08:50 +00:00
return ;
}
2018-08-12 14:03:07 +00:00
session . getRegionSelector ( player . getWorld ( ) ) . explainPrimarySelection ( player , session , pos ) ;
2014-04-03 02:08:50 +00:00
}
@Command (
2018-08-12 14:03:07 +00:00
aliases = { " /pos2 " , " posb " , " /2 " } ,
usage = " [coordinates] " ,
desc = " Set position 2 " ,
min = 0 ,
max = 1
2014-04-03 02:08:50 +00:00
)
@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
2019-04-03 13:25:16 +00:00
BlockVector3 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-10-19 20:13:32 +00:00
pos = BlockVector3 . at ( Integer . parseInt ( coords [ 0 ] ) ,
2014-04-03 02:08:50 +00:00
Integer . parseInt ( coords [ 1 ] ) ,
Integer . parseInt ( coords [ 2 ] ) ) ;
} else {
2018-08-12 14:03:07 +00:00
BBC . SELECTOR_INVALID_COORDINATES . send ( player , args . getString ( 0 ) ) ;
2014-04-03 02:08:50 +00:00
return ;
}
} else {
2019-03-31 16:09:20 +00:00
pos = player . getBlockIn ( ) . toBlockPoint ( ) ;
2014-04-03 02:08:50 +00:00
}
2018-08-12 14:03:07 +00:00
pos = pos . clampY ( 0 , player . getWorld ( ) . getMaximumPoint ( ) . getBlockY ( ) ) ;
if ( ! session . getRegionSelector ( player . getWorld ( ) ) . selectSecondary ( pos , ActorSelectorLimits . forActor ( player ) ) ) {
BBC . SELECTOR_ALREADY_SET . send ( player ) ;
2014-04-03 02:08:50 +00:00
return ;
}
session . getRegionSelector ( player . getWorld ( ) )
2018-08-12 14:03:07 +00:00
. explainSecondarySelection ( player , session , pos ) ;
2014-04-03 02:08:50 +00:00
}
@Command (
2018-08-12 14:03:07 +00:00
aliases = { " /hpos1 " } ,
usage = " " ,
desc = " Set position 1 to targeted block " ,
min = 0 ,
max = 0
2014-04-03 02:08:50 +00:00
)
@CommandPermissions ( " worldedit.selection.hpos " )
2019-04-03 05:53:34 +00:00
public void hpos1 ( Player player , LocalSession session , CommandContext args ) throws WorldEditException {
2019-03-31 16:09:20 +00:00
BlockVector3 pos = player . getBlockTrace ( 300 ) . toBlockPoint ( ) ;
2014-04-03 02:08:50 +00:00
if ( pos ! = null ) {
2018-08-12 14:03:07 +00:00
if ( ! session . getRegionSelector ( player . getWorld ( ) ) . selectPrimary ( pos , ActorSelectorLimits . forActor ( player ) ) ) {
BBC . SELECTOR_ALREADY_SET . send ( player ) ;
2014-04-03 02:08:50 +00:00
return ;
}
session . getRegionSelector ( player . getWorld ( ) )
2018-08-12 14:03:07 +00:00
. explainPrimarySelection ( player , session , pos ) ;
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 (
2018-08-12 14:03:07 +00:00
aliases = { " /hpos2 " } ,
usage = " " ,
desc = " Set position 2 to targeted block " ,
min = 0 ,
max = 0
2014-04-03 02:08:50 +00:00
)
@CommandPermissions ( " worldedit.selection.hpos " )
2019-04-03 05:53:34 +00:00
public void hpos2 ( Player player , LocalSession session , CommandContext args ) throws WorldEditException {
2019-03-31 16:09:20 +00:00
BlockVector3 pos = player . getBlockTrace ( 300 ) . toBlockPoint ( ) ;
2014-04-03 02:08:50 +00:00
if ( pos ! = null ) {
2018-08-12 14:03:07 +00:00
if ( ! session . getRegionSelector ( player . getWorld ( ) ) . selectSecondary ( pos , ActorSelectorLimits . forActor ( player ) ) ) {
BBC . SELECTOR_ALREADY_SET . send ( player ) ;
2014-04-03 02:08:50 +00:00
return ;
}
session . getRegionSelector ( player . getWorld ( ) )
2018-08-12 14:03:07 +00:00
. explainSecondarySelection ( player , session , pos ) ;
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 (
2018-08-12 14:03:07 +00:00
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
2014-04-03 02:08:50 +00:00
)
@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-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 ( ) ;
2014-04-03 02:08:50 +00:00
if ( args . hasFlag ( 's' ) ) {
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 ;
2014-04-03 02:08:50 +00:00
if ( args . argsLength ( ) = = 1 ) {
// coords specified
String [ ] coords = args . getString ( 0 ) . split ( " , " ) ;
if ( coords . length ! = 2 ) {
2018-08-12 14:03:07 +00:00
BBC . SELECTOR_INVALID_COORDINATES . send ( player , args . getString ( 0 ) ) ;
2014-04-03 02:08:50 +00:00
}
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-12-23 16:19:33 +00:00
min2D = ( args . hasFlag ( 'c' ) ) ? pos : ChunkStore . toChunk ( pos . toBlockVector3 ( ) ) ;
2014-04-03 02:08:50 +00:00
} else {
// use player loc
2019-03-31 16:09:20 +00:00
min2D = ChunkStore . toChunk ( player . getBlockIn ( ) . 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 (
2018-08-12 14:03:07 +00:00
aliases = { " /wand " , " /w " } ,
usage = " " ,
desc = " Get the wand object " ,
min = 0 ,
max = 0
2014-04-03 02:08:50 +00:00
)
@CommandPermissions ( " worldedit.wand " )
2019-03-16 23:04:24 +00:00
public void wand ( Player player ) throws WorldEditException {
2019-01-31 15:08:58 +00:00
player . giveItem ( new BaseItemStack ( ItemTypes . parse ( we . getConfiguration ( ) . wandItem ) , 1 ) ) ;
2018-08-12 14:03:07 +00:00
BBC . SELECTION_WAND . send ( player ) ;
if ( ! FawePlayer . wrap ( 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 (
2018-08-12 14:03:07 +00:00
aliases = { " toggleeditwand " } ,
usage = " " ,
desc = " Toggle functionality of the edit wand " ,
min = 0 ,
max = 0
2014-04-03 02:08:50 +00:00
)
@CommandPermissions ( " worldedit.wand.toggle " )
2018-08-12 14:03:07 +00:00
public void toggleWand ( Player player , LocalSession session , CommandContext args ) throws WorldEditException {
2019-06-06 01:17:34 +00:00
2014-04-03 02:08:50 +00:00
session . setToolControl ( ! session . isToolControlEnabled ( ) ) ;
if ( session . isToolControlEnabled ( ) ) {
2018-08-12 14:03:07 +00:00
BBC . SELECTION_WAND_ENABLE . m ( ) . send ( player ) ;
2014-04-03 02:08:50 +00:00
} else {
2018-08-12 14:03:07 +00:00
BBC . SELECTION_WAND_DISABLE . send ( player ) ;
2014-04-03 02:08:50 +00:00
}
}
@Command (
2018-08-12 14:03:07 +00:00
aliases = { " /expand " } ,
usage = " <amount> [reverse-amount] <direction> " ,
desc = " Expand the selection area " ,
min = 1 ,
max = 3
2014-04-03 02:08:50 +00:00
)
@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.
2018-08-12 14:03:07 +00:00
if ( args . getString ( 0 ) . equalsIgnoreCase ( " vert " ) | | args . getString ( 0 ) . equalsIgnoreCase ( " vertical " ) ) {
2014-04-03 02:08:50 +00:00
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 ) ;
2018-08-12 14:03:07 +00:00
BBC . SELECTION_EXPAND_VERT . send ( player , ( newSize - oldSize ) ) ;
2014-04-03 02:08:50 +00:00
} catch ( RegionOperationException e ) {
player . printError ( e . getMessage ( ) ) ;
}
return ;
}
2018-12-23 16:19:33 +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 ( ) ) {
2018-08-12 14:03:07 +00:00
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
2014-04-03 02:08:50 +00:00
reverseChange = args . getInteger ( 1 ) ;
2018-08-12 14:03:07 +00:00
if ( args . getString ( 2 ) . contains ( " , " ) ) {
String [ ] split = args . getString ( 2 ) . split ( " , " ) ;
2014-04-03 02:08:50 +00:00
for ( String s : split ) {
dirs . add ( we . getDirection ( player , s . toLowerCase ( ) ) ) ;
}
} else {
2018-08-12 14:03:07 +00:00
dirs . add ( we . getDirection ( player , args . getString ( 2 ) . toLowerCase ( ) ) ) ;
2014-04-03 02:08:50 +00:00
}
2018-08-12 14:03:07 +00:00
break ;
2014-04-03 02:08:50 +00:00
2018-08-12 14:03:07 +00:00
default :
dirs . add ( we . getDirection ( player , " me " ) ) ;
break ;
2014-04-03 02:08:50 +00:00
}
Region region = session . getSelection ( player . getWorld ( ) ) ;
int oldSize = region . getArea ( ) ;
if ( reverseChange = = 0 ) {
2018-12-23 16:19:33 +00:00
for ( BlockVector3 dir : dirs ) {
2014-04-03 02:08:50 +00:00
region . expand ( dir . multiply ( change ) ) ;
}
} else {
2018-12-23 16:19:33 +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 ( ) ;
2018-08-12 14:03:07 +00:00
session . getRegionSelector ( player . getWorld ( ) ) . explainRegionAdjust ( player , session ) ;
BBC . SELECTION_EXPAND . send ( player , ( newSize - oldSize ) ) ;
2014-04-03 02:08:50 +00:00
}
@Command (
2018-08-12 14:03:07 +00:00
aliases = { " /contract " } ,
usage = " <amount> [reverse-amount] [direction] " ,
desc = " Contract the selection area " ,
min = 1 ,
max = 3
2014-04-03 02:08:50 +00:00
)
@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 {
2018-12-23 16:19:33 +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 ( ) ) {
2018-08-12 14:03:07 +00:00
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
2014-04-03 02:08:50 +00:00
reverseChange = args . getInteger ( 1 ) ;
2018-08-12 14:03:07 +00:00
if ( args . getString ( 2 ) . contains ( " , " ) ) {
String [ ] split = args . getString ( 2 ) . split ( " , " ) ;
2014-04-03 02:08:50 +00:00
for ( String s : split ) {
dirs . add ( we . getDirection ( player , s . toLowerCase ( ) ) ) ;
}
} else {
2018-08-12 14:03:07 +00:00
dirs . add ( we . getDirection ( player , args . getString ( 2 ) . toLowerCase ( ) ) ) ;
2014-04-03 02:08:50 +00:00
}
2018-08-12 14:03:07 +00:00
break ;
2014-04-03 02:08:50 +00:00
2018-08-12 14:03:07 +00:00
default :
dirs . add ( we . getDirection ( player , " me " ) ) ;
break ;
2014-04-03 02:08:50 +00:00
}
try {
Region region = session . getSelection ( player . getWorld ( ) ) ;
int oldSize = region . getArea ( ) ;
if ( reverseChange = = 0 ) {
2018-12-23 16:19:33 +00:00
for ( BlockVector3 dir : dirs ) {
2014-04-03 02:08:50 +00:00
region . contract ( dir . multiply ( change ) ) ;
}
} else {
2018-12-23 16:19:33 +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 ( ) ;
2018-08-12 14:03:07 +00:00
session . getRegionSelector ( player . getWorld ( ) ) . explainRegionAdjust ( player , session ) ;
2014-04-03 02:08:50 +00:00
2018-08-12 14:03:07 +00:00
BBC . SELECTION_CONTRACT . send ( player , ( oldSize - newSize ) ) ;
2014-04-03 02:08:50 +00:00
} catch ( RegionOperationException e ) {
player . printError ( e . getMessage ( ) ) ;
}
}
@Command (
2018-08-12 14:03:07 +00:00
aliases = { " /shift " } ,
usage = " <amount> [direction] " ,
desc = " Shift the selection area " ,
min = 1 ,
max = 2
2014-04-03 02:08:50 +00:00
)
@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 {
2018-12-23 16:19:33 +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-12-23 16:19:33 +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 ) ;
2018-08-12 14:03:07 +00:00
BBC . SELECTION_SHIFT . send ( player ) ;
2014-04-03 02:08:50 +00:00
} catch ( RegionOperationException e ) {
player . printError ( e . getMessage ( ) ) ;
}
}
@Command (
2018-08-12 14:03:07 +00:00
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
2014-04-03 02:08:50 +00:00
)
@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 ) ;
2018-08-12 14:03:07 +00:00
BBC . SELECTION_OUTSET . send ( player ) ;
2014-04-03 02:08:50 +00:00
}
@Command (
2018-08-12 14:03:07 +00:00
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
2014-04-03 02:08:50 +00:00
)
@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 ) ;
2018-08-12 14:03:07 +00:00
BBC . SELECTION_INSET . send ( player ) ;
2014-04-03 02:08:50 +00:00
}
2018-12-23 16:19:33 +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' ) ) {
2018-10-19 20:13:32 +00:00
changes . add ( ( BlockVector3 . at ( 0 , 1 , 0 ) ) . multiply ( change ) ) ;
changes . add ( ( BlockVector3 . at ( 0 , - 1 , 0 ) ) . multiply ( change ) ) ;
2014-04-03 02:08:50 +00:00
}
if ( ! args . hasFlag ( 'v' ) ) {
2018-10-19 20:13:32 +00:00
changes . add ( ( BlockVector3 . at ( 1 , 0 , 0 ) ) . multiply ( change ) ) ;
changes . add ( ( BlockVector3 . at ( - 1 , 0 , 0 ) ) . multiply ( change ) ) ;
changes . add ( ( BlockVector3 . at ( 0 , 0 , 1 ) ) . multiply ( change ) ) ;
changes . add ( ( BlockVector3 . at ( 0 , 0 , - 1 ) ) . multiply ( change ) ) ;
2014-04-03 02:08:50 +00:00
}
2018-12-23 16:19:33 +00:00
return changes . toArray ( new BlockVector3 [ 0 ] ) ;
2014-04-03 02:08:50 +00:00
}
@Command (
2018-08-12 14:03:07 +00:00
aliases = { " /size " } ,
flags = " c " ,
usage = " " ,
desc = " Get information about the selection " ,
min = 0 ,
max = 0
2014-04-03 02:08:50 +00:00
)
@CommandPermissions ( " worldedit.selection.size " )
2019-01-09 07:13:44 +00:00
public void size ( Player player , LocalSession session , EditSession editSession , CommandContext args ) throws WorldEditException {
2014-04-03 02:08:50 +00:00
if ( args . hasFlag ( 'c' ) ) {
2018-08-12 14:03:07 +00:00
ClipboardHolder root = session . getClipboard ( ) ;
// Clipboard clipboard = holder.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 ) ;
}
Region region = clipboard . getRegion ( ) ;
2019-01-09 07:13:44 +00:00
BlockVector3 size = region . getMaximumPoint ( ) . subtract ( region . getMinimumPoint ( ) ) . add ( BlockVector3 . ONE ) ;
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 + + ;
}
2019-06-06 01:17:34 +00:00
// player.print("Cuboid dimensions (max - min): " + size);
// player.print("Offset: " + origin);
// player.print("Cuboid distance: " + size.distance(Vector.ONE));
// player.print("# of blocks: " + (int) (size.getX() * size.getY() * size.getZ()));
2019-01-09 07:13:44 +00:00
//=======
// public void size(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
// if (args.hasFlag('c')) {
// ClipboardHolder holder = session.getClipboard();
// Clipboard clipboard = holder.getClipboard();
// Region region = clipboard.getRegion();
// BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint());
// BlockVector3 origin = clipboard.getOrigin();
//
// player.print("Cuboid dimensions (max - min): " + size);
// player.print("Offset: " + origin);
// player.print("Cuboid distance: " + size.distance(BlockVector3.ONE));
// player.print("# of blocks: " + (int) (size.getX() * size.getY() * size.getZ()));
2014-04-03 02:08:50 +00:00
return ;
}
2018-08-12 14:03:07 +00:00
2014-04-03 02:08:50 +00:00
Region region = session . getSelection ( player . getWorld ( ) ) ;
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 ( " Type: " + session . getRegionSelector ( player . getWorld ( ) )
2014-04-03 02:08:50 +00:00
. getTypeName ( ) ) ;
2018-08-12 14:03:07 +00:00
2014-04-03 02:08:50 +00:00
for ( String line : session . getRegionSelector ( player . getWorld ( ) )
. getInformationLines ( ) ) {
2019-06-06 01:17:34 +00:00
player . print ( line ) ;
2014-04-03 02:08:50 +00:00
}
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 (
2018-08-12 14:03:07 +00:00
aliases = { " /count " } ,
2019-04-05 04:48:41 +00:00
usage = " <mask> " ,
2018-08-12 14:03:07 +00:00
desc = " Counts the number of a certain type of block " ,
flags = " d " ,
min = 1 ,
max = 1
2014-04-03 02:08:50 +00:00
)
@CommandPermissions ( " worldedit.analysis.count " )
2018-08-12 14:03:07 +00:00
public void count ( Player player , LocalSession session , EditSession editSession , Mask mask ) throws WorldEditException {
int count = editSession . countBlock ( session . getSelection ( player . getWorld ( ) ) , mask ) ;
BBC . SELECTION_COUNT . send ( player , count ) ;
2014-04-03 02:08:50 +00:00
}
@Command (
2018-08-12 14:03:07 +00:00
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. " ,
flags = " c " ,
min = 0 ,
max = 0
2014-04-03 02:08:50 +00:00
)
@CommandPermissions ( " worldedit.analysis.distr " )
2018-08-12 14:03:07 +00:00
public void distr ( Player player , LocalSession session , EditSession editSession , @Switch ( 'c' ) boolean useClipboard , @Switch ( 'd' ) boolean useData ) throws WorldEditException , CommandException {
2014-04-03 02:08:50 +00:00
int size ;
2018-08-12 14:03:07 +00:00
List < Countable > distributionData ;
Region region ;
if ( useClipboard ) {
// TODO multi clipboard distribution
Clipboard clipboard = session . getClipboard ( ) . getClipboard ( ) ;
region = clipboard . getRegion ( ) ;
editSession . setExtent ( 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
}
2018-08-12 14:03:07 +00:00
if ( useData )
distributionData = ( List ) editSession . getBlockDistributionWithData ( region ) ;
else
distributionData = ( List ) editSession . getBlockDistribution ( region ) ;
size = session . getSelection ( player . getWorld ( ) ) . getArea ( ) ;
2014-04-03 02:08:50 +00:00
2018-08-12 14:03:07 +00:00
if ( distributionData . size ( ) < = 0 ) {
2019-06-06 01:17:34 +00:00
player . printError ( " No blocks counted. " ) ;
2014-04-03 02:08:50 +00:00
return ;
}
2018-08-12 14:03:07 +00:00
BBC . SELECTION_DISTR . send ( player , size ) ;
for ( Countable c : distributionData ) {
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 (
2018-08-12 14:03:07 +00:00
aliases = { " /sel " , " ; " , " /desel " , " /deselect " } ,
flags = " d " ,
usage = " [cuboid|extend|poly|ellipsoid|sphere|cyl|convex] " ,
desc = " Choose a region selector " ,
min = 0 ,
max = 1
2014-04-03 02:08:50 +00:00
)
2019-04-03 13:25:16 +00:00
public void select ( Player player , LocalSession session , EditSession editSession , 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 ) ;
2018-08-12 14:03:07 +00:00
BBC . SELECTION_CLEARED . send ( player ) ;
2014-04-03 02:08:50 +00:00
return ;
}
final String typeName = args . getString ( 0 ) ;
final RegionSelector oldSelector = session . getRegionSelector ( world ) ;
final RegionSelector selector ;
if ( typeName . equalsIgnoreCase ( " cuboid " ) ) {
selector = new CuboidRegionSelector ( oldSelector ) ;
2019-06-06 01:17:34 +00:00
player . print ( BBC . SEL_CUBOID . s ( ) ) ;
2014-04-03 02:08:50 +00:00
} else if ( typeName . equalsIgnoreCase ( " extend " ) ) {
selector = new ExtendingCuboidRegionSelector ( oldSelector ) ;
2019-06-06 01:17:34 +00:00
player . print ( BBC . SEL_CUBOID_EXTEND . s ( ) ) ;
2014-04-03 02:08:50 +00:00
} else if ( typeName . equalsIgnoreCase ( " poly " ) ) {
2014-07-29 02:50:01 +00:00
selector = new Polygonal2DRegionSelector ( oldSelector ) ;
2019-06-06 01:17:34 +00:00
player . print ( BBC . SEL_2D_POLYGON . s ( ) ) ;
2014-07-29 02:50:01 +00:00
Optional < Integer > limit = ActorSelectorLimits . forActor ( player ) . getPolygonVertexLimit ( ) ;
2019-06-06 01:17:34 +00:00
limit . ifPresent ( integer - > player . print ( BBC . SEL_MAX . f ( integer ) ) ) ;
player . print ( BBC . SEL_LIST . s ( ) ) ;
2014-04-03 02:08:50 +00:00
} else if ( typeName . equalsIgnoreCase ( " ellipsoid " ) ) {
selector = new EllipsoidRegionSelector ( oldSelector ) ;
2019-06-06 01:17:34 +00:00
player . print ( BBC . SEL_ELLIPSIOD . s ( ) ) ;
2014-04-03 02:08:50 +00:00
} else if ( typeName . equalsIgnoreCase ( " sphere " ) ) {
selector = new SphereRegionSelector ( oldSelector ) ;
2019-06-06 01:17:34 +00:00
player . print ( BBC . SEL_SPHERE . s ( ) ) ;
2014-04-03 02:08:50 +00:00
} else if ( typeName . equalsIgnoreCase ( " cyl " ) ) {
selector = new CylinderRegionSelector ( oldSelector ) ;
2019-06-06 01:17:34 +00:00
player . print ( BBC . SEL_CYLINDRICAL . s ( ) ) ;
2018-08-12 14:03:07 +00:00
} else if ( typeName . equalsIgnoreCase ( " convex " ) | | typeName . equalsIgnoreCase ( " hull " ) ) {
2014-07-29 02:50:01 +00:00
selector = new ConvexPolyhedralRegionSelector ( oldSelector ) ;
2019-06-06 01:17:34 +00:00
player . print ( BBC . SEL_CONVEX_POLYHEDRAL . s ( ) ) ;
2018-08-12 14:03:07 +00:00
Optional < Integer > limit = ActorSelectorLimits . forActor ( player ) . getPolyhedronVertexLimit ( ) ;
2019-06-06 01:17:34 +00:00
limit . ifPresent ( integer - > player . print ( BBC . SEL_MAX . f ( integer ) ) ) ;
player . print ( BBC . SEL_LIST . s ( ) ) ;
2018-08-12 14:03:07 +00:00
} else if ( typeName . equalsIgnoreCase ( " polyhedral " ) | | typeName . equalsIgnoreCase ( " polyhedron " ) ) {
selector = new PolyhedralRegionSelector ( player . getWorld ( ) ) ;
2019-06-06 01:17:34 +00:00
player . print ( BBC . SEL_CONVEX_POLYHEDRAL . s ( ) ) ;
2014-07-29 02:50:01 +00:00
Optional < Integer > limit = ActorSelectorLimits . forActor ( player ) . getPolyhedronVertexLimit ( ) ;
2019-06-06 01:17:34 +00:00
limit . ifPresent ( integer - > player . print ( BBC . SEL_MAX . f ( integer ) ) ) ;
player . print ( BBC . SEL_LIST . s ( ) ) ;
2018-08-12 14:03:07 +00:00
} else if ( typeName . startsWith ( " fuzzy " ) | | typeName . startsWith ( " magic " ) ) {
Mask mask ;
if ( typeName . length ( ) > 6 ) {
ParserContext parserContext = new ParserContext ( ) ;
parserContext . setActor ( player ) ;
parserContext . setWorld ( player . getWorld ( ) ) ;
parserContext . setSession ( session ) ;
parserContext . setExtent ( editSession ) ;
mask = we . getMaskFactory ( ) . parseFromInput ( typeName . substring ( 6 ) , parserContext ) ;
} else {
mask = new IdMask ( editSession ) ;
}
selector = new FuzzyRegionSelector ( player , editSession , mask ) ;
2019-06-06 01:17:34 +00:00
player . print ( BBC . SEL_FUZZY . f ( ) ) ;
player . print ( BBC . SEL_LIST . f ( ) ) ;
2014-04-03 02:08:50 +00:00
} else {
2014-07-29 02:56:04 +00:00
CommandListBox box = new CommandListBox ( " Selection modes " ) ;
StyledFragment contents = box . getContents ( ) ;
StyledFragment tip = contents . createFragment ( Style . RED ) ;
2019-06-06 01:17:34 +00:00
tip . append ( BBC . SEL_MODES . s ( ) ) . newLine ( ) ;
2018-08-12 14:03:07 +00:00
box . appendCommand ( " //sel cuboid " , " Select two corners of a cuboid " ) ;
box . appendCommand ( " //sel extend " , " Fast cuboid selection mode " ) ;
box . appendCommand ( " //sel poly " , " Select a 2D polygon with height " ) ;
box . appendCommand ( " //sel ellipsoid " , " Select an ellipsoid " ) ;
box . appendCommand ( " //sel sphere " , " Select a sphere " ) ;
box . appendCommand ( " //sel cyl " , " Select a cylinder " ) ;
box . appendCommand ( " //sel convex " , " Select a convex polyhedral " ) ;
box . appendCommand ( " //sel polyhedral " , " Select a hollow polyhedral " ) ;
box . appendCommand ( " //sel fuzzy[=<mask>] " , " Select all connected blocks (magic wand) " ) ;
2014-07-29 02:56:04 +00:00
player . printRaw ( ColorCodeBuilder . asColorCodes ( box ) ) ;
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 ) ;
2018-08-12 14:03:07 +00:00
BBC . SELECTOR_SET_DEFAULT . send ( player , found . name ( ) ) ;
2014-07-29 03:53:17 +00:00
} 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 ) ;
}
2018-08-12 16:36:39 +00:00
2019-06-06 01:17:34 +00:00
}