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-22 02:49:08 +00:00
import static com.google.common.base.Preconditions.checkNotNull ;
2018-08-12 14:03:07 +00:00
import com.boydti.fawe.Fawe ;
import com.boydti.fawe.config.BBC ;
import com.boydti.fawe.config.Settings ;
import com.boydti.fawe.object.FaweLimit ;
2019-07-06 00:46:48 +00:00
import com.boydti.fawe.object.brush.BlendBall ;
import com.boydti.fawe.object.brush.BlobBrush ;
import com.boydti.fawe.object.brush.BrushSettings ;
import com.boydti.fawe.object.brush.CatenaryBrush ;
import com.boydti.fawe.object.brush.CircleBrush ;
import com.boydti.fawe.object.brush.CommandBrush ;
import com.boydti.fawe.object.brush.CopyPastaBrush ;
import com.boydti.fawe.object.brush.ErodeBrush ;
import com.boydti.fawe.object.brush.FallingSphere ;
import com.boydti.fawe.object.brush.FlattenBrush ;
import com.boydti.fawe.object.brush.HeightBrush ;
import com.boydti.fawe.object.brush.ImageBrush ;
import com.boydti.fawe.object.brush.LayerBrush ;
import com.boydti.fawe.object.brush.LineBrush ;
import com.boydti.fawe.object.brush.PopulateSchem ;
import com.boydti.fawe.object.brush.RaiseBrush ;
import com.boydti.fawe.object.brush.RecurseBrush ;
import com.boydti.fawe.object.brush.ScatterBrush ;
import com.boydti.fawe.object.brush.ScatterCommand ;
import com.boydti.fawe.object.brush.ScatterOverlayBrush ;
import com.boydti.fawe.object.brush.ShatterBrush ;
import com.boydti.fawe.object.brush.SplatterBrush ;
import com.boydti.fawe.object.brush.SplineBrush ;
import com.boydti.fawe.object.brush.StencilBrush ;
import com.boydti.fawe.object.brush.SurfaceSphereBrush ;
import com.boydti.fawe.object.brush.SurfaceSpline ;
2018-08-12 14:03:07 +00:00
import com.boydti.fawe.object.brush.heightmap.ScalableHeightMap ;
2019-08-26 04:45:03 +00:00
import com.boydti.fawe.object.brush.heightmap.ScalableHeightMap.Shape ;
2018-08-12 14:03:07 +00:00
import com.boydti.fawe.object.brush.sweep.SweepBrush ;
import com.boydti.fawe.object.clipboard.MultiClipboardHolder ;
2019-08-29 12:57:03 +00:00
import com.boydti.fawe.object.io.PGZIPOutputStream ;
2018-08-12 14:03:07 +00:00
import com.boydti.fawe.object.mask.IdMask ;
2019-08-29 12:57:03 +00:00
import com.boydti.fawe.util.MainUtil ;
2018-08-12 14:03:07 +00:00
import com.boydti.fawe.util.MathMan ;
2019-07-21 11:39:36 +00:00
import com.boydti.fawe.util.StringMan ;
2018-08-12 14:03:07 +00:00
import com.boydti.fawe.util.image.ImageUtil ;
import com.sk89q.minecraft.util.commands.Step ;
2018-12-23 16:19:33 +00:00
import com.sk89q.worldedit.EditSession ;
2019-04-04 10:28:41 +00:00
import com.sk89q.worldedit.EmptyClipboardException ;
2018-12-23 16:19:33 +00:00
import com.sk89q.worldedit.LocalSession ;
import com.sk89q.worldedit.WorldEdit ;
import com.sk89q.worldedit.WorldEditException ;
2019-08-29 12:57:03 +00:00
import com.sk89q.worldedit.blocks.BaseItem ;
2019-10-23 04:23:52 +00:00
import com.sk89q.worldedit.command.argument.Arguments ;
2019-07-22 02:49:08 +00:00
import com.sk89q.worldedit.command.factory.TreeGeneratorFactory ;
2019-07-06 00:46:48 +00:00
import com.sk89q.worldedit.command.tool.BrushTool ;
2019-07-21 11:39:36 +00:00
import com.sk89q.worldedit.command.tool.InvalidToolBindException ;
2019-04-04 10:28:41 +00:00
import com.sk89q.worldedit.command.tool.brush.Brush ;
2018-12-23 16:19:33 +00:00
import com.sk89q.worldedit.command.tool.brush.ButcherBrush ;
import com.sk89q.worldedit.command.tool.brush.ClipboardBrush ;
import com.sk89q.worldedit.command.tool.brush.CylinderBrush ;
import com.sk89q.worldedit.command.tool.brush.GravityBrush ;
import com.sk89q.worldedit.command.tool.brush.HollowCylinderBrush ;
import com.sk89q.worldedit.command.tool.brush.HollowSphereBrush ;
2019-07-22 02:49:08 +00:00
import com.sk89q.worldedit.command.tool.brush.OperationFactoryBrush ;
2018-12-23 16:19:33 +00:00
import com.sk89q.worldedit.command.tool.brush.SmoothBrush ;
import com.sk89q.worldedit.command.tool.brush.SphereBrush ;
2019-07-06 00:46:48 +00:00
import com.sk89q.worldedit.command.util.CommandPermissions ;
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator ;
2014-07-16 02:47:47 +00:00
import com.sk89q.worldedit.command.util.CreatureButcher ;
2014-06-28 02:55:38 +00:00
import com.sk89q.worldedit.entity.Player ;
2019-07-06 00:46:48 +00:00
import com.sk89q.worldedit.extension.platform.Actor ;
2019-07-22 06:47:12 +00:00
import com.sk89q.worldedit.extension.platform.binding.ProvideBindings ;
2014-06-30 00:47:08 +00:00
import com.sk89q.worldedit.extent.clipboard.Clipboard ;
2019-01-31 15:08:58 +00:00
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats ;
2019-07-22 02:49:08 +00:00
import com.sk89q.worldedit.function.Contextual ;
import com.sk89q.worldedit.function.factory.Deform ;
import com.sk89q.worldedit.function.factory.Paint ;
2018-08-12 14:03:07 +00:00
import com.sk89q.worldedit.function.mask.ExistingBlockMask ;
import com.sk89q.worldedit.function.mask.Mask ;
import com.sk89q.worldedit.function.mask.SingleBlockTypeMask ;
2019-07-22 02:49:08 +00:00
import com.sk89q.worldedit.function.operation.Operation ;
2014-06-28 02:55:38 +00:00
import com.sk89q.worldedit.function.pattern.Pattern ;
2019-08-15 19:21:24 +00:00
import com.sk89q.worldedit.internal.annotation.ClipboardMask ;
2019-07-21 11:39:36 +00:00
import com.sk89q.worldedit.internal.annotation.Range ;
2018-08-21 16:58:10 +00:00
import com.sk89q.worldedit.internal.expression.Expression ;
2019-08-06 20:18:44 +00:00
import com.sk89q.worldedit.internal.expression.runtime.EvaluationException ;
2018-12-23 16:19:33 +00:00
import com.sk89q.worldedit.math.BlockVector3 ;
import com.sk89q.worldedit.math.Vector3 ;
2019-07-22 02:49:08 +00:00
import com.sk89q.worldedit.regions.factory.RegionFactory ;
2014-07-02 09:56:21 +00:00
import com.sk89q.worldedit.session.ClipboardHolder ;
2019-07-22 02:49:08 +00:00
import com.sk89q.worldedit.util.HandSide ;
import com.sk89q.worldedit.util.TreeGenerator ;
2019-07-21 11:39:36 +00:00
import com.sk89q.worldedit.world.block.BlockID ;
import com.sk89q.worldedit.world.block.BlockState ;
2018-08-12 14:03:07 +00:00
import com.sk89q.worldedit.world.block.BlockStateHolder ;
2019-07-06 00:46:48 +00:00
import com.sk89q.worldedit.world.block.BlockType ;
import com.sk89q.worldedit.world.block.BlockTypes ;
2018-08-12 14:03:07 +00:00
import java.awt.image.BufferedImage ;
2019-08-29 12:57:03 +00:00
import java.io.DataInputStream ;
import java.io.DataOutputStream ;
2019-07-06 00:46:48 +00:00
import java.io.File ;
import java.io.FileInputStream ;
import java.io.FileNotFoundException ;
2019-08-29 12:57:03 +00:00
import java.io.FileOutputStream ;
2019-07-06 00:46:48 +00:00
import java.io.IOException ;
import java.io.InputStream ;
2018-09-02 21:46:35 +00:00
import java.net.URI ;
2019-08-29 12:57:03 +00:00
import java.nio.file.FileSystems ;
2018-08-12 14:03:07 +00:00
import java.util.List ;
2019-08-29 12:57:03 +00:00
import java.util.zip.GZIPInputStream ;
2019-07-22 02:49:08 +00:00
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.ArgFlag ;
import org.enginehub.piston.annotation.param.Switch ;
import org.enginehub.piston.inject.InjectedValueAccess ;
2019-10-23 04:23:52 +00:00
import org.enginehub.piston.inject.Key ;
2014-06-28 02:55:38 +00:00
2014-04-03 02:08:50 +00:00
/ * *
2014-06-28 02:55:38 +00:00
* Commands to set brush shape .
2014-04-03 02:08:50 +00:00
* /
2019-07-06 00:46:48 +00:00
@CommandContainer ( superTypes = CommandPermissionsConditionGenerator . Registration . class )
2019-07-22 20:58:18 +00:00
public class BrushCommands {
2019-07-06 00:46:48 +00:00
private final WorldEdit worldEdit ;
2014-06-28 02:55:38 +00:00
2019-07-06 00:46:48 +00:00
/ * *
* Create a new instance .
*
* @param worldEdit reference to WorldEdit
* /
2014-06-28 02:55:38 +00:00
public BrushCommands ( WorldEdit worldEdit ) {
2019-07-06 00:46:48 +00:00
checkNotNull ( worldEdit ) ;
this . worldEdit = worldEdit ;
2014-04-04 21:11:48 +00:00
}
2014-04-03 02:08:50 +00:00
@Command (
2019-07-17 05:43:18 +00:00
name = " blendball " ,
aliases = { " bb " , " blend " } ,
2018-08-12 14:03:07 +00:00
desc = " Smooths and blends terrain " ,
2019-07-17 05:43:18 +00:00
descFooter = " Smooths and blends terrain \ n " +
2019-11-11 21:02:28 +00:00
" Pic: https://i.imgur.com/cNUQUkj.png → https://i.imgur.com/hFOFsNf.png "
2018-08-12 14:03:07 +00:00
)
@CommandPermissions ( " worldedit.brush.blendball " )
2019-10-23 04:23:52 +00:00
public void blendBallBrush ( InjectedValueAccess context ,
2019-07-06 00:46:48 +00:00
@Arg ( desc = " The radius to sample for blending " , def = " 5 " )
2019-09-21 01:52:35 +00:00
Expression radius ) throws WorldEditException {
2019-08-15 19:21:24 +00:00
worldEdit . checkMaxBrushRadius ( radius ) ;
2019-10-23 04:23:52 +00:00
set ( context , new BlendBall ( ) ) . setSize ( radius ) ;
2018-08-12 14:03:07 +00:00
}
@Command (
2019-07-06 00:46:48 +00:00
name = " erode " ,
desc = " Erodes terrain "
2018-08-12 14:03:07 +00:00
)
@CommandPermissions ( " worldedit.brush.erode " )
2019-10-23 04:23:52 +00:00
public void erodeBrush ( InjectedValueAccess context ,
2019-07-06 00:46:48 +00:00
@Arg ( desc = " The radius for eroding " , def = " 5 " )
2019-10-23 04:23:52 +00:00
Expression radius ,
@Arg ( desc = " erodeFaces " , def = " 6 " ) int erodefaces ,
@Arg ( desc = " erodeRec " , def = " 0 " ) int erodeRec ,
@Arg ( desc = " fillFaces " , def = " 1 " ) int fillFaces ,
@Arg ( desc = " fillRec " , def = " 1 " ) int fillRec
) throws WorldEditException {
2019-08-15 19:21:24 +00:00
worldEdit . checkMaxBrushRadius ( radius ) ;
2019-10-23 04:23:52 +00:00
set ( context , new ErodeBrush ( erodefaces , erodeRec , fillFaces , fillRec ) ) . setSize ( radius ) ;
2018-08-12 14:03:07 +00:00
}
@Command (
2019-07-06 00:46:48 +00:00
name = " pull " ,
desc = " Pull terrain towards you "
2018-08-12 14:03:07 +00:00
)
@CommandPermissions ( " worldedit.brush.pull " )
2019-10-23 04:23:52 +00:00
public void pullBrush ( InjectedValueAccess context ,
2019-07-06 00:46:48 +00:00
@Arg ( desc = " The radius to sample for blending " , def = " 5 " )
2019-10-23 04:23:52 +00:00
Expression radius ,
@Arg ( desc = " erodeFaces " , def = " 2 " ) int erodefaces ,
@Arg ( desc = " erodeRec " , def = " 1 " ) int erodeRec ,
@Arg ( desc = " fillFaces " , def = " 5 " ) int fillFaces ,
@Arg ( desc = " fillRec " , def = " 1 " ) int fillRec
) throws WorldEditException {
2019-08-15 19:21:24 +00:00
worldEdit . checkMaxBrushRadius ( radius ) ;
2019-10-23 04:23:52 +00:00
set ( context , new RaiseBrush ( erodefaces , erodeRec , fillFaces , fillRec ) ) . setSize ( radius ) ;
2018-08-12 14:03:07 +00:00
}
@Command (
2019-07-06 00:46:48 +00:00
name = " circle " ,
2019-11-11 21:02:28 +00:00
desc = " Creates a circle, which revolves around your facing direction "
2014-04-03 02:08:50 +00:00
)
@CommandPermissions ( " worldedit.brush.sphere " )
2019-10-23 04:23:52 +00:00
public void circleBrush ( Player player , InjectedValueAccess context ,
2019-09-21 01:52:35 +00:00
Pattern fill ,
2019-07-06 00:46:48 +00:00
@Arg ( desc = " The radius to sample for blending " , def = " 5 " )
2019-09-21 01:52:35 +00:00
Expression radius ) throws WorldEditException {
2019-08-15 19:21:24 +00:00
worldEdit . checkMaxBrushRadius ( radius ) ;
2019-10-23 04:23:52 +00:00
set ( context , new CircleBrush ( player ) ) . setSize ( radius ) . setFill ( fill ) ;
2018-08-12 14:03:07 +00:00
}
@Command (
2019-07-17 05:43:18 +00:00
name = " recursive " ,
aliases = { " recurse " , " r " } ,
2018-08-12 14:03:07 +00:00
desc = " Set all connected blocks " ,
2019-07-17 05:43:18 +00:00
descFooter = " Set all connected blocks \ n " +
2019-07-06 00:46:48 +00:00
" Note: Set a mask to recurse along specific blocks "
2018-08-12 14:03:07 +00:00
)
@CommandPermissions ( " worldedit.brush.recursive " )
2019-10-23 04:23:52 +00:00
public void recursiveBrush ( InjectedValueAccess context , EditSession editSession ,
2019-09-21 01:52:35 +00:00
Pattern fill ,
2019-07-06 00:46:48 +00:00
@Arg ( desc = " The radius to sample for blending " , def = " 5 " )
2019-08-15 19:21:24 +00:00
Expression radius ,
2019-07-23 02:22:32 +00:00
@Switch ( name = 'd' , desc = " Apply in depth first order " )
2019-09-21 01:52:35 +00:00
boolean depthFirst ) throws WorldEditException {
2019-08-15 19:21:24 +00:00
worldEdit . checkMaxBrushRadius ( radius ) ;
2019-10-23 04:23:52 +00:00
set ( context , new RecurseBrush ( depthFirst ) )
2019-08-26 04:45:03 +00:00
. setSize ( radius ) . setFill ( fill ) . setMask ( new IdMask ( editSession ) ) ;
2018-08-12 14:03:07 +00:00
}
@Command (
2019-07-17 05:43:18 +00:00
name = " line " ,
aliases = { " l " } ,
2019-07-22 06:47:12 +00:00
desc = " Create lines "
2018-08-12 14:03:07 +00:00
)
@CommandPermissions ( " worldedit.brush.line " )
2019-10-23 04:23:52 +00:00
public void lineBrush ( InjectedValueAccess context , Pattern fill ,
2019-07-06 00:46:48 +00:00
@Arg ( desc = " The radius to sample for blending " , def = " 0 " )
2019-08-15 19:21:24 +00:00
Expression radius ,
2019-07-23 02:22:32 +00:00
@Switch ( name = 'h' , desc = " Create only a shell " )
2019-07-22 02:49:08 +00:00
boolean shell ,
2019-07-23 02:22:32 +00:00
@Switch ( name = 's' , desc = " Selects the clicked point after drawing " )
2019-07-22 02:49:08 +00:00
boolean select ,
2019-07-23 02:22:32 +00:00
@Switch ( name = 'f' , desc = " Create a flat line " )
2019-09-21 01:52:35 +00:00
boolean flat ) throws WorldEditException {
2019-08-15 19:21:24 +00:00
worldEdit . checkMaxBrushRadius ( radius ) ;
2019-10-23 04:23:52 +00:00
set ( context , new LineBrush ( shell , select , flat ) ) . setSize ( radius ) . setFill ( fill ) ;
2018-08-12 14:03:07 +00:00
}
@Command (
2019-07-17 05:43:18 +00:00
name = " spline " ,
aliases = { " spl " , " curve " } ,
2018-08-12 14:03:07 +00:00
desc = " Join multiple objects together in a curve " ,
2019-07-17 05:43:18 +00:00
descFooter = " Click to select some objects,click the same block twice to connect the objects. \ n " +
2018-08-12 14:03:07 +00:00
" Insufficient brush radius, or clicking the the wrong spot will result in undesired shapes. The shapes must be simple lines or loops. \ n " +
" Pic1: http://i.imgur.com/CeRYAoV.jpg -> http://i.imgur.com/jtM0jA4.png \ n " +
" Pic2: http://i.imgur.com/bUeyc72.png -> http://i.imgur.com/tg6MkcF.png " +
2019-07-06 00:46:48 +00:00
" Tutorial: https://www.planetminecraft.com/blog/fawe-tutorial/ "
2018-08-12 14:03:07 +00:00
)
@CommandPermissions ( " worldedit.brush.spline " )
2019-10-23 04:23:52 +00:00
public void splineBrush ( Player player , InjectedValueAccess context ,
2019-09-21 01:52:35 +00:00
Pattern fill ,
2019-07-06 00:46:48 +00:00
@Arg ( desc = " The radius to sample for blending " , def = " 25 " )
2019-09-21 01:52:35 +00:00
Expression radius ) throws WorldEditException {
2019-08-15 19:21:24 +00:00
worldEdit . checkMaxBrushRadius ( radius ) ;
player . print ( BBC . BRUSH_SPLINE . format ( radius ) ) ;
2019-10-23 04:23:52 +00:00
set ( context ,
new SplineBrush ( player ) )
2019-08-15 19:21:24 +00:00
. setSize ( radius )
2019-07-21 11:39:36 +00:00
. setFill ( fill ) ;
2018-08-12 14:03:07 +00:00
}
@Command (
2019-07-17 05:43:18 +00:00
name = " sweep " ,
aliases = { " sw " , " vaesweep " } ,
2018-08-12 14:03:07 +00:00
desc = " Sweep your clipboard content along a curve " ,
2019-07-17 05:43:18 +00:00
descFooter = " Sweeps your clipboard content along a curve. \ n " +
2019-07-06 00:46:48 +00:00
" Define a curve by selecting the individual points with a brush \ n " +
" Set [copies] to a value > 0 if you want to have your selection pasted a limited amount of times equally spaced on the curve "
2018-08-12 14:03:07 +00:00
)
@CommandPermissions ( " worldedit.brush.sweep " )
2019-10-23 04:23:52 +00:00
public void sweepBrush ( Player player , InjectedValueAccess context ,
2019-11-11 21:02:28 +00:00
@Arg ( desc = " int " , def = " -1 " ) int copies ) throws WorldEditException {
2019-06-12 21:12:12 +00:00
player . print ( BBC . BRUSH_SPLINE . s ( ) ) ;
2019-10-23 04:23:52 +00:00
set ( context , new SweepBrush ( copies ) ) ;
2018-08-12 14:03:07 +00:00
}
2014-04-03 02:08:50 +00:00
2018-08-12 14:03:07 +00:00
@Command (
2019-07-17 05:43:18 +00:00
name = " catenary " ,
aliases = { " cat " , " gravityline " , " saggedline " } ,
2019-07-22 02:49:08 +00:00
desc = " Create a hanging line between two points "
2018-08-12 14:03:07 +00:00
)
@CommandPermissions ( " worldedit.brush.spline " )
2019-10-23 04:23:52 +00:00
public void catenaryBrush ( InjectedValueAccess context , Pattern fill ,
2019-09-21 01:52:35 +00:00
@Arg ( def = " 1.2 " , desc = " Length of wire compared to distance between points " ) @Range ( min = 1 ) double lengthFactor ,
2019-07-06 00:46:48 +00:00
@Arg ( desc = " The radius to sample for blending " , def = " 0 " )
2019-08-15 19:21:24 +00:00
Expression radius ,
2019-07-23 02:22:32 +00:00
@Switch ( name = 'h' , desc = " Create only a shell " )
2019-07-22 02:49:08 +00:00
boolean shell ,
2019-07-23 02:22:32 +00:00
@Switch ( name = 's' , desc = " Select the clicked point after drawing " )
2019-07-22 02:49:08 +00:00
boolean select ,
2019-07-23 02:22:32 +00:00
@Switch ( name = 'd' , desc = " sags the catenary toward the facing direction " )
2019-09-21 01:52:35 +00:00
boolean facingDirection ) throws WorldEditException {
2019-08-15 19:21:24 +00:00
worldEdit . checkMaxBrushRadius ( radius ) ;
2019-07-06 00:46:48 +00:00
Brush brush = new CatenaryBrush ( shell , select , facingDirection , lengthFactor ) ;
2019-10-23 04:23:52 +00:00
set ( context ,
2019-09-21 01:52:35 +00:00
new CatenaryBrush ( shell , select , facingDirection , lengthFactor ) )
2019-08-15 19:21:24 +00:00
. setSize ( radius )
2019-07-21 11:39:36 +00:00
. setFill ( fill ) ;
2018-08-12 14:03:07 +00:00
}
2014-04-03 02:08:50 +00:00
2018-08-12 14:03:07 +00:00
@Command (
2019-07-22 20:58:18 +00:00
name = " surfacespline " ,
aliases = { " sspline " , " sspl " } ,
2018-08-12 14:03:07 +00:00
desc = " Draws a spline (curved line) on the surface " ,
2019-07-17 05:43:18 +00:00
descFooter = " Create a spline on the surface \ n " +
2019-07-06 00:46:48 +00:00
" Video: https://www.youtube.com/watch?v=zSN-2jJxXlM "
2018-08-12 14:03:07 +00:00
)
@CommandPermissions ( " worldedit.brush.surfacespline " ) // 0, 0, 0, 10, 0,
2019-10-23 04:23:52 +00:00
public void surfaceSpline ( Player player , InjectedValueAccess context , Pattern fill ,
2019-07-06 00:46:48 +00:00
@Arg ( desc = " The radius to sample for blending " , def = " 0 " )
2019-11-11 21:02:28 +00:00
Expression radius ,
@Arg ( desc = " double " , def = " 0 " ) double tension ,
@Arg ( desc = " double " , def = " 0 " ) double bias ,
@Arg ( desc = " double " , def = " 0 " ) double continuity ,
@Arg ( desc = " double " , def = " 10 " ) double quality ) throws WorldEditException {
2019-08-15 19:21:24 +00:00
player . print ( BBC . BRUSH_SPLINE . format ( radius ) ) ;
worldEdit . checkMaxBrushRadius ( radius ) ;
2019-10-23 04:23:52 +00:00
set ( context ,
2019-09-21 01:52:35 +00:00
new SurfaceSpline ( tension , bias , continuity , quality ) )
2019-08-15 19:21:24 +00:00
. setSize ( radius )
2019-07-21 11:39:36 +00:00
. setFill ( fill ) ;
2018-08-12 14:03:07 +00:00
}
@Command (
2019-07-17 05:43:18 +00:00
name = " rock " ,
aliases = { " blob " } ,
2019-07-06 00:46:48 +00:00
desc = " Creates a distorted sphere "
2018-08-12 14:03:07 +00:00
)
@CommandPermissions ( " worldedit.brush.rock " )
2019-10-23 04:23:52 +00:00
public void blobBrush ( InjectedValueAccess context , Pattern fill ,
2019-11-11 21:02:28 +00:00
@Arg ( desc = " Vector3 " , def = " 10 " )
2019-09-21 01:52:35 +00:00
Vector3 radius ,
2019-11-11 21:02:28 +00:00
@Arg ( desc = " double " , def = " 100 " )
2019-09-21 01:52:35 +00:00
double sphericity ,
2019-11-11 21:02:28 +00:00
@Arg ( desc = " double " , def = " 30 " )
2019-09-21 01:52:35 +00:00
double frequency ,
2019-11-11 21:02:28 +00:00
@Arg ( desc = " double " , def = " 50 " )
2019-09-21 01:52:35 +00:00
double amplitude ) throws WorldEditException {
2018-12-23 16:19:33 +00:00
double max = MathMan . max ( radius . getX ( ) , radius . getY ( ) , radius . getZ ( ) ) ;
2019-07-06 00:46:48 +00:00
worldEdit . checkMaxBrushRadius ( max ) ;
2018-08-12 14:03:07 +00:00
Brush brush = new BlobBrush ( radius . divide ( max ) , frequency / 100 , amplitude / 100 , sphericity / 100 ) ;
2019-10-23 04:23:52 +00:00
set ( context , brush ) . setSize ( max ) . setFill ( fill ) ;
2018-08-12 14:03:07 +00:00
}
@Command (
2019-07-06 00:46:48 +00:00
name = " sphere " ,
aliases = { " s " } ,
desc = " Choose the sphere brush "
2018-08-12 14:03:07 +00:00
)
@CommandPermissions ( " worldedit.brush.sphere " )
2019-10-23 04:23:52 +00:00
public void sphereBrush ( Player player , InjectedValueAccess context ,
2019-07-06 00:46:48 +00:00
@Arg ( desc = " The pattern of blocks to set " )
Pattern pattern ,
@Arg ( desc = " The radius of the sphere " , def = " 2 " )
2019-08-15 19:21:24 +00:00
Expression radius ,
2019-07-06 00:46:48 +00:00
@Switch ( name = 'h' , desc = " Create hollow spheres instead " )
boolean hollow ,
@Switch ( name = 'f' , desc = " Create falling spheres instead " )
2019-09-21 01:52:35 +00:00
boolean falling ) throws WorldEditException {
2019-08-15 19:21:24 +00:00
worldEdit . checkMaxBrushRadius ( radius ) ;
2018-08-12 14:03:07 +00:00
Brush brush ;
2014-06-28 02:55:38 +00:00
if ( hollow ) {
2018-08-12 14:03:07 +00:00
brush = new HollowSphereBrush ( ) ;
2014-04-03 02:08:50 +00:00
} else {
2019-07-21 11:39:36 +00:00
if ( pattern instanceof BlockStateHolder ) {
BlockType type = ( ( BlockStateHolder ) pattern ) . getBlockType ( ) ;
switch ( type . getInternalId ( ) ) {
case BlockID . SAND :
case BlockID . GRAVEL :
2019-11-02 19:53:25 +00:00
player . print ( BBC . BRUSH_TRY_OTHER . s ( ) ) ;
2019-07-21 11:39:36 +00:00
falling = true ;
2018-08-12 14:03:07 +00:00
}
}
if ( falling ) {
brush = new FallingSphere ( ) ;
} else {
brush = new SphereBrush ( ) ;
}
2014-04-03 02:08:50 +00:00
}
2019-10-23 04:23:52 +00:00
set ( context , brush ) . setSize ( radius ) . setFill ( pattern ) ;
2018-08-12 14:03:07 +00:00
}
2014-04-03 02:08:50 +00:00
2018-08-12 14:03:07 +00:00
@Command (
2019-07-17 05:43:18 +00:00
name = " shatter " ,
aliases = { " partition " , " split " } ,
2018-08-12 14:03:07 +00:00
desc = " Creates random lines to break the terrain into pieces " ,
2019-07-17 05:43:18 +00:00
descFooter = " Creates uneven lines separating terrain into multiple pieces \ n " +
2019-07-06 00:46:48 +00:00
" Pic: https://i.imgur.com/2xKsZf2.png "
2018-08-12 14:03:07 +00:00
)
@CommandPermissions ( " worldedit.brush.shatter " )
2019-10-23 04:23:52 +00:00
public void shatterBrush ( EditSession editSession , InjectedValueAccess context ,
2019-09-21 01:52:35 +00:00
Pattern fill ,
2019-07-06 00:46:48 +00:00
@Arg ( desc = " The radius to sample for blending " , def = " 10 " )
2019-09-21 01:52:35 +00:00
Expression radius ,
@Arg ( desc = " Lines " , def = " 10 " ) int count ) throws WorldEditException {
2019-08-15 19:21:24 +00:00
worldEdit . checkMaxBrushRadius ( radius ) ;
2019-10-23 04:23:52 +00:00
set ( context ,
2019-09-21 01:52:35 +00:00
new ShatterBrush ( count ) )
2019-08-15 19:21:24 +00:00
. setSize ( radius )
2019-07-21 11:39:36 +00:00
. setFill ( fill )
. setMask ( new ExistingBlockMask ( editSession ) ) ;
2014-04-03 02:08:50 +00:00
}
@Command (
2019-07-17 05:43:18 +00:00
name = " stencil " ,
2018-08-12 14:03:07 +00:00
desc = " Use a height map to paint a surface " ,
2019-07-22 02:49:08 +00:00
descFooter = " Use a height map to paint any surface. \ n "
2019-07-17 05:43:18 +00:00
)
2018-08-12 14:03:07 +00:00
@CommandPermissions ( " worldedit.brush.stencil " )
2019-10-23 04:23:52 +00:00
public void stencilBrush ( LocalSession session , InjectedValueAccess context , Pattern fill ,
2019-11-11 21:02:28 +00:00
@Arg ( desc = " Expression " , def = " 5 " ) Expression radius ,
@Arg ( desc = " String " , def = " " ) String image ,
2019-09-21 01:52:35 +00:00
@Arg ( def = " 0 " , desc = " rotation " ) @Range ( min = 0 , max = 360 ) int rotation ,
2019-11-11 21:02:28 +00:00
@Arg ( desc = " double " , def = " 1 " ) double yscale ,
2019-09-21 01:52:35 +00:00
@Switch ( name = 'w' , desc = " Apply at maximum saturation " ) boolean onlyWhite ,
@Switch ( name = 'r' , desc = " Apply random rotation " ) boolean randomRotate ) throws WorldEditException , FileNotFoundException {
2019-08-15 19:21:24 +00:00
worldEdit . checkMaxBrushRadius ( radius ) ;
2018-08-12 14:03:07 +00:00
InputStream stream = getHeightmapStream ( image ) ;
HeightBrush brush ;
try {
2018-09-07 17:11:56 +00:00
brush = new StencilBrush ( stream , rotation , yscale , onlyWhite , " #clipboard " . equalsIgnoreCase ( image ) ? session . getClipboard ( ) . getClipboard ( ) : null ) ;
2018-08-12 14:03:07 +00:00
} catch ( EmptyClipboardException ignore ) {
brush = new StencilBrush ( stream , rotation , yscale , onlyWhite , null ) ;
}
if ( randomRotate ) {
brush . setRandomRotate ( true ) ;
}
2019-10-23 04:23:52 +00:00
set ( context ,
2019-09-21 01:52:35 +00:00
brush )
2019-08-15 19:21:24 +00:00
. setSize ( radius )
2019-07-21 11:39:36 +00:00
. setFill ( fill ) ;
2018-08-12 14:03:07 +00:00
}
@Command (
2019-07-17 05:43:18 +00:00
name = " image " ,
aliases = { " color " } ,
2018-08-12 14:03:07 +00:00
desc = " Use a height map to paint a surface " ,
2019-07-22 02:49:08 +00:00
descFooter = " Use a height map to paint any surface. \ n " )
2018-08-12 14:03:07 +00:00
@CommandPermissions ( " worldedit.brush.stencil " )
2019-10-23 04:23:52 +00:00
public void imageBrush ( LocalSession session , InjectedValueAccess context ,
2019-11-11 21:02:28 +00:00
@Arg ( desc = " Expression " , def = " 5 " )
2019-09-21 01:52:35 +00:00
Expression radius ,
ProvideBindings . ImageUri imageUri ,
@Arg ( def = " 1 " , desc = " scale height " ) @Range ( min = Double . MIN_NORMAL )
double yscale ,
@Switch ( name = 'a' , desc = " Use image Alpha " )
boolean alpha ,
@Switch ( name = 'f' , desc = " Blend the image with existing terrain " )
boolean fadeOut ) throws WorldEditException , IOException {
2018-08-17 10:13:33 +00:00
BufferedImage image = imageUri . load ( ) ;
2019-08-15 19:21:24 +00:00
worldEdit . checkMaxBrushRadius ( radius ) ;
2018-08-12 14:03:07 +00:00
if ( yscale ! = 1 ) {
ImageUtil . scaleAlpha ( image , yscale ) ;
alpha = true ;
}
if ( fadeOut ) {
ImageUtil . fadeAlpha ( image ) ;
alpha = true ;
}
ImageBrush brush = new ImageBrush ( image , session , alpha ) ;
2019-10-23 04:23:52 +00:00
set ( context , brush ) . setSize ( radius ) ;
2018-08-12 14:03:07 +00:00
}
2014-04-03 02:08:50 +00:00
2018-08-12 14:03:07 +00:00
@Command (
2019-07-17 05:43:18 +00:00
name = " surface " ,
aliases = { " surf " } ,
2018-08-12 14:03:07 +00:00
desc = " Use a height map to paint a surface " ,
2019-07-17 05:43:18 +00:00
descFooter = " Use a height map to paint any surface. \ n " +
2019-07-06 00:46:48 +00:00
" The -w flag will only apply at maximum saturation \ n " +
2019-07-17 05:43:18 +00:00
" The -r flag will apply random rotation "
2019-07-23 02:22:32 +00:00
)
2019-07-21 11:39:36 +00:00
@CommandPermissions ( " worldedit.brush.surface " )
2019-10-23 04:23:52 +00:00
public void surfaceBrush ( InjectedValueAccess context , Pattern fill ,
2019-11-11 21:02:28 +00:00
@Arg ( desc = " Expression " , def = " 5 " )
2019-09-21 01:52:35 +00:00
Expression radius ) throws WorldEditException {
2019-08-15 19:21:24 +00:00
worldEdit . checkMaxBrushRadius ( radius ) ;
2019-10-23 04:23:52 +00:00
set ( context , new SurfaceSphereBrush ( ) ) . setFill ( fill ) . setSize ( radius ) ;
2018-08-12 14:03:07 +00:00
}
2014-04-03 02:08:50 +00:00
2018-08-12 14:03:07 +00:00
@Command (
2019-07-06 00:46:48 +00:00
name = " scatter " ,
2018-08-12 14:03:07 +00:00
desc = " Scatter a pattern on a surface " ,
2019-07-17 05:43:18 +00:00
descFooter = " Set a number of blocks randomly on a surface each a certain distance apart. \ n " +
" Video: https://youtu.be/RPZIaTbqoZw?t=34s "
2019-07-23 02:22:32 +00:00
)
2018-08-12 14:03:07 +00:00
@CommandPermissions ( " worldedit.brush.scatter " )
2019-10-23 04:23:52 +00:00
public void scatterBrush ( InjectedValueAccess context , Pattern fill ,
2019-11-11 21:02:28 +00:00
@Arg ( desc = " Expression " , def = " 5 " ) Expression radius ,
@Arg ( desc = " double " , def = " 5 " ) double points ,
@Arg ( desc = " double " , def = " 1 " ) double distance ,
2019-09-21 01:52:35 +00:00
@Switch ( name = 'o' , desc = " Overlay the block " ) boolean overlay ) throws WorldEditException {
2019-08-15 19:21:24 +00:00
worldEdit . checkMaxBrushRadius ( radius ) ;
2018-08-12 14:03:07 +00:00
Brush brush ;
if ( overlay ) {
2019-11-11 21:02:28 +00:00
brush = new ScatterOverlayBrush ( ( int ) points , ( int ) distance ) ;
2014-04-03 02:08:50 +00:00
} else {
2019-11-11 21:02:28 +00:00
brush = new ScatterBrush ( ( int ) points , ( int ) distance ) ;
2014-04-03 02:08:50 +00:00
}
2019-10-23 04:23:52 +00:00
set ( context , brush ) . setSize ( radius ) . setFill ( fill ) ;
2018-08-12 14:03:07 +00:00
}
2014-04-03 02:08:50 +00:00
2018-08-12 14:03:07 +00:00
@Command (
2019-07-17 05:43:18 +00:00
name = " populateschematic " ,
aliases = { " populateschem " , " popschem " , " pschem " , " ps " } ,
2019-07-23 02:22:32 +00:00
desc = " Scatter a schematic on a surface "
2018-08-12 14:03:07 +00:00
)
@CommandPermissions ( " worldedit.brush.populateschematic " )
2019-10-23 04:23:52 +00:00
public void scatterSchemBrush ( Player player , InjectedValueAccess context , Mask mask ,
2019-09-21 01:52:35 +00:00
@Arg ( name = " clipboard " , desc = " Clipboard uri " ) String clipboardStr ,
2019-11-11 21:02:28 +00:00
@Arg ( desc = " Expression " , def = " 30 " ) Expression radius ,
@Arg ( desc = " double " , def = " 50 " ) double density ,
2019-09-21 01:52:35 +00:00
@Switch ( name = 'r' , desc = " Apply random rotation " ) boolean rotate ) throws WorldEditException {
2019-08-15 19:21:24 +00:00
worldEdit . checkMaxBrushRadius ( radius ) ;
2018-08-12 14:03:07 +00:00
try {
2019-08-06 15:32:05 +00:00
MultiClipboardHolder clipboards = ClipboardFormats . loadAllFromInput ( player , clipboardStr , null , true ) ;
2018-08-12 14:03:07 +00:00
if ( clipboards = = null ) {
2019-08-06 15:32:05 +00:00
BBC . SCHEMATIC_NOT_FOUND . send ( player , clipboardStr ) ;
2019-08-26 04:45:03 +00:00
return ;
2018-08-12 14:03:07 +00:00
}
List < ClipboardHolder > holders = clipboards . getHolders ( ) ;
if ( holders = = null ) {
2019-08-06 15:32:05 +00:00
BBC . SCHEMATIC_NOT_FOUND . send ( player , clipboardStr ) ;
2019-08-26 04:45:03 +00:00
return ;
2018-08-12 14:03:07 +00:00
}
2019-10-23 04:23:52 +00:00
set ( context ,
2019-09-21 01:52:35 +00:00
new PopulateSchem ( mask , holders , ( int ) density , rotate ) ) . setSize ( radius ) ;
2018-08-12 14:03:07 +00:00
} catch ( IOException e ) {
throw new RuntimeException ( e ) ;
}
2014-04-03 02:08:50 +00:00
}
@Command (
2019-07-06 00:46:48 +00:00
name = " layer " ,
2018-08-12 14:03:07 +00:00
desc = " Replaces terrain with a layer. " ,
2019-07-17 05:43:18 +00:00
descFooter = " Replaces terrain with a layer. \ n " +
2019-07-06 00:46:48 +00:00
" Example: /br layer 5 95:1 95:2 35:15 - Places several layers on a surface \ n " +
" Pic: https://i.imgur.com/XV0vYoX.png "
2018-08-12 14:03:07 +00:00
)
@CommandPermissions ( " worldedit.brush.layer " )
2019-10-23 04:23:52 +00:00
public void surfaceLayer ( InjectedValueAccess context ,
2019-11-11 21:02:28 +00:00
@Arg ( desc = " Expression " ) Expression radius , List < BlockState > blockLayers ) throws WorldEditException {
2019-07-06 00:46:48 +00:00
worldEdit . checkMaxBrushRadius ( radius ) ;
2019-10-23 04:23:52 +00:00
set ( context , new LayerBrush ( blockLayers . toArray ( new BlockState [ 0 ] ) ) ) . setSize ( radius ) ;
2018-08-12 14:03:07 +00:00
}
@Command (
2019-07-06 00:46:48 +00:00
name = " splatter " ,
2018-08-12 14:03:07 +00:00
desc = " Splatter a pattern on a surface " ,
2019-07-17 05:43:18 +00:00
descFooter = " Sets a bunch of blocks randomly on a surface. \ n " +
2019-07-06 00:46:48 +00:00
" Pic: https://i.imgur.com/hMD29oO.png \ n " +
" Example: /br splatter stone,dirt 30 15 \ n " +
" Note: The seeds define how many splotches there are, recursion defines how large, solid defines whether the pattern is applied per seed, else per block. "
2018-08-12 14:03:07 +00:00
)
@CommandPermissions ( " worldedit.brush.splatter " )
2019-10-23 04:23:52 +00:00
public void splatterBrush ( InjectedValueAccess context , Pattern fill ,
2019-11-11 21:02:28 +00:00
@Arg ( desc = " Expression " , def = " 5 " ) Expression radius ,
@Arg ( desc = " double " , def = " 1 " ) double points ,
@Arg ( desc = " double " , def = " 5 " ) double recursion ,
@Arg ( desc = " boolean " , def = " true " ) boolean solid ) throws WorldEditException {
2019-08-15 19:21:24 +00:00
worldEdit . checkMaxBrushRadius ( radius ) ;
2019-11-11 21:02:28 +00:00
set ( context , new SplatterBrush ( ( int ) points , ( int ) recursion , solid ) ) . setSize ( radius ) . setFill ( fill ) ;
2018-08-12 14:03:07 +00:00
}
@Command (
2019-07-22 20:58:18 +00:00
name = " scattercommand " ,
aliases = { " scattercmd " , " scmd " , " scommand " } ,
2018-08-12 14:03:07 +00:00
desc = " Run commands at random points on a surface " ,
2019-07-17 05:43:18 +00:00
descFooter =
2018-08-12 14:03:07 +00:00
" Run commands at random points on a surface \ n " +
" - The scatter radius is the min distance between each point \ n " +
" - Your selection will be expanded to the specified size around each point \ n " +
2019-07-06 00:46:48 +00:00
" - Placeholders: {x}, {y}, {z}, {world}, {size} "
2018-08-12 14:03:07 +00:00
)
@CommandPermissions ( " worldedit.brush.scattercommand " )
2019-10-23 04:23:52 +00:00
public void scatterCommandBrush ( Player player , InjectedValueAccess context ,
2019-11-11 21:02:28 +00:00
@Arg ( desc = " Expression " ) Expression radius , double points ,
2019-09-21 01:52:35 +00:00
double distance , List < String > commandStr ) throws WorldEditException {
2019-07-06 00:46:48 +00:00
worldEdit . checkMaxBrushRadius ( radius ) ;
2019-10-23 04:23:52 +00:00
set ( context ,
2019-09-21 01:52:35 +00:00
new ScatterCommand ( ( int ) points , ( int ) distance , StringMan . join ( commandStr , " " ) ) )
2019-07-21 11:39:36 +00:00
. setSize ( radius ) ;
2018-08-12 14:03:07 +00:00
}
@Command (
2019-07-06 00:46:48 +00:00
name = " cylinder " ,
aliases = { " cyl " , " c " } ,
desc = " Choose the cylinder brush "
2018-08-12 14:03:07 +00:00
)
@CommandPermissions ( " worldedit.brush.cylinder " )
2019-10-23 04:23:52 +00:00
public void cylinderBrush ( InjectedValueAccess context ,
2019-07-06 00:46:48 +00:00
@Arg ( desc = " The pattern of blocks to set " )
Pattern pattern ,
@Arg ( desc = " The radius of the cylinder " , def = " 2 " )
2019-08-15 19:21:24 +00:00
Expression radius ,
2019-07-06 00:46:48 +00:00
@Arg ( desc = " The height of the cylinder " , def = " 1 " )
int height ,
@Switch ( name = 'h' , desc = " Create hollow cylinders instead " )
2019-09-21 01:52:35 +00:00
boolean hollow ) throws WorldEditException {
2019-08-15 19:21:24 +00:00
worldEdit . checkMaxBrushRadius ( radius ) ;
2019-07-06 00:46:48 +00:00
worldEdit . checkMaxBrushRadius ( height ) ;
2018-08-12 14:03:07 +00:00
BrushSettings settings ;
if ( hollow ) {
2019-10-23 04:23:52 +00:00
settings = set ( context , new HollowCylinderBrush ( height ) ) ;
2018-08-12 14:03:07 +00:00
} else {
2019-10-23 04:23:52 +00:00
settings = set ( context , new CylinderBrush ( height ) ) ;
2018-08-12 14:03:07 +00:00
}
2019-09-21 01:52:35 +00:00
settings . setSize ( radius ) . setFill ( pattern ) ;
2018-08-12 14:03:07 +00:00
}
@Command (
2019-07-06 00:46:48 +00:00
name = " clipboard " ,
2019-08-23 07:36:33 +00:00
desc = " @Deprecated use instead: `/br copypaste`) " ,
2019-07-17 05:43:18 +00:00
descFooter = " Chooses the clipboard brush. \ n " +
2019-07-06 00:46:48 +00:00
" Without the -p flag, the paste will appear centered at the target location. " +
" With the flag, then the paste will appear relative to where you had " +
" stood relative to the copied area when you copied it. "
2014-04-03 02:08:50 +00:00
)
2019-08-23 07:36:33 +00:00
@Deprecated
2014-04-03 02:08:50 +00:00
@CommandPermissions ( " worldedit.brush.clipboard " )
2019-10-23 04:23:52 +00:00
public void clipboardBrush ( LocalSession session , InjectedValueAccess context ,
2019-09-21 01:52:35 +00:00
@Switch ( name = 'a' , desc = " Don't paste air from the clipboard " )
boolean ignoreAir ,
@Switch ( name = 'o' , desc = " Paste starting at the target location, instead of centering on it " )
boolean usingOrigin ,
@Switch ( name = 'e' , desc = " Skip paste entities if available " )
boolean skipEntities ,
@Switch ( name = 'b' , desc = " Paste biomes if available " )
boolean pasteBiomes ,
@ArgFlag ( name = 'm' , desc = " Skip blocks matching this mask in the clipboard " , def = " " )
@ClipboardMask
Mask sourceMask ) throws WorldEditException {
2014-07-02 09:56:21 +00:00
ClipboardHolder holder = session . getClipboard ( ) ;
2019-09-21 01:52:35 +00:00
2014-07-02 09:56:21 +00:00
Clipboard clipboard = holder . getClipboard ( ) ;
2019-08-15 19:21:24 +00:00
ClipboardHolder newHolder = new ClipboardHolder ( clipboard ) ;
newHolder . setTransform ( holder . getTransform ( ) ) ;
2014-04-03 02:08:50 +00:00
2018-12-23 16:19:33 +00:00
BlockVector3 size = clipboard . getDimensions ( ) ;
2014-04-03 02:08:50 +00:00
2019-08-15 19:21:24 +00:00
worldEdit . checkMaxBrushRadius ( size . getBlockX ( ) / 2D - 1 ) ;
worldEdit . checkMaxBrushRadius ( size . getBlockY ( ) / 2D - 1 ) ;
worldEdit . checkMaxBrushRadius ( size . getBlockZ ( ) / 2D - 1 ) ;
2019-10-23 04:23:52 +00:00
set ( context ,
2019-09-21 01:52:35 +00:00
new ClipboardBrush ( newHolder , ignoreAir , usingOrigin , ! skipEntities , pasteBiomes , sourceMask ) ) ;
2014-04-03 02:08:50 +00:00
}
@Command (
2019-07-06 00:46:48 +00:00
name = " smooth " ,
desc = " Choose the terrain softener brush " ,
descFooter = " Example: '/brush smooth 2 4 grass_block,dirt,stone' "
2014-04-03 02:08:50 +00:00
)
@CommandPermissions ( " worldedit.brush.smooth " )
2019-10-23 04:23:52 +00:00
public void smoothBrush ( Player player , InjectedValueAccess context , EditSession editSession ,
2019-09-21 01:52:35 +00:00
@Arg ( desc = " The radius to sample for softening " , def = " 2 " )
Expression radius ,
@Arg ( desc = " The number of iterations to perform " , def = " 4 " )
int iterations ,
@Arg ( desc = " The mask of blocks to use for the heightmap " , def = " " )
Mask maskOpt ) throws WorldEditException {
2019-08-15 19:21:24 +00:00
worldEdit . checkMaxBrushRadius ( radius ) ;
2014-04-03 02:08:50 +00:00
2019-09-14 03:05:16 +00:00
FaweLimit limit = Settings . IMP . getLimit ( player ) ;
2018-08-12 14:03:07 +00:00
iterations = Math . min ( limit . MAX_ITERATIONS , iterations ) ;
2014-04-03 02:08:50 +00:00
2019-10-23 04:23:52 +00:00
set ( context ,
2019-09-21 01:52:35 +00:00
new SmoothBrush ( iterations , maskOpt ) )
2019-08-15 19:21:24 +00:00
. setSize ( radius ) ;
2014-04-03 02:08:50 +00:00
}
@Command (
2019-07-06 00:46:48 +00:00
name = " extinguish " ,
aliases = { " ex " } ,
desc = " Shortcut fire extinguisher brush "
2014-04-03 02:08:50 +00:00
)
@CommandPermissions ( " worldedit.brush.ex " )
2019-10-23 04:23:52 +00:00
public void extinguishBrush ( InjectedValueAccess context , EditSession editSession ,
2019-09-21 01:52:35 +00:00
@Arg ( desc = " The radius to extinguish " , def = " 5 " )
Expression radius ) throws WorldEditException {
2019-08-15 19:21:24 +00:00
worldEdit . checkMaxBrushRadius ( radius ) ;
2018-08-12 14:03:07 +00:00
2019-10-23 04:23:52 +00:00
set ( context ,
2019-09-21 01:52:35 +00:00
new SphereBrush ( ) )
2019-08-15 19:21:24 +00:00
. setSize ( radius )
2019-09-21 01:52:35 +00:00
. setFill ( BlockTypes . AIR . getDefaultState ( ) )
2019-07-21 11:39:36 +00:00
. setMask ( new SingleBlockTypeMask ( editSession , BlockTypes . FIRE ) ) ;
2014-04-03 02:08:50 +00:00
}
@Command (
2019-07-06 00:46:48 +00:00
name = " gravity " ,
aliases = { " grav " } ,
desc = " Gravity brush, simulates the effect of gravity "
2014-04-03 02:08:50 +00:00
)
@CommandPermissions ( " worldedit.brush.gravity " )
2019-10-23 04:23:52 +00:00
public void gravityBrush ( InjectedValueAccess context ,
2019-07-06 00:46:48 +00:00
@Arg ( desc = " The radius to apply gravity in " , def = " 5 " )
2019-09-21 01:52:35 +00:00
Expression radius ,
2019-07-06 00:46:48 +00:00
@Switch ( name = 'h' , desc = " Affect blocks starting at max Y, rather than the target location Y + radius " )
2019-09-21 01:52:35 +00:00
boolean fromMaxY ) throws WorldEditException {
2019-08-15 19:21:24 +00:00
worldEdit . checkMaxBrushRadius ( radius ) ;
2019-07-06 00:46:48 +00:00
2019-10-23 04:23:52 +00:00
set ( context , new GravityBrush ( fromMaxY ) ) . setSize ( radius ) ;
2018-08-12 14:03:07 +00:00
}
2014-04-03 02:08:50 +00:00
2018-08-12 14:03:07 +00:00
@Command (
2019-07-17 05:43:18 +00:00
name = " height " ,
aliases = { " heightmap " } ,
2018-08-12 14:03:07 +00:00
desc = " Raise or lower terrain using a heightmap " ,
2019-07-17 05:43:18 +00:00
descFooter = " This brush raises and lowers land. \ n " +
2019-07-06 00:46:48 +00:00
" - The `-r` flag enables random off-axis rotation \ n " +
" - The `-l` flag will work on snow layers \ n " +
" - The `-s` flag disables smoothing \ n " +
" Note: Use a negative yscale to reduce height \ n " +
" Snow Pic: https://i.imgur.com/Hrzn0I4.png "
2018-08-12 14:03:07 +00:00
)
@CommandPermissions ( " worldedit.brush.height " )
2019-11-11 21:02:28 +00:00
public void heightBrush ( LocalSession session , @Arg ( desc = " Expression " , def = " 5 " ) Expression radius , @Arg ( desc = " String " , def = " " ) String image , @Arg ( def = " 0 " , desc = " rotation " ) @Range ( min = 0 , max = 360 ) int rotation , @Arg ( desc = " double " , def = " 1 " ) double yscale , @Switch ( name = 'r' , desc = " TODO " ) boolean randomRotate , @Switch ( name = 'l' , desc = " TODO " ) boolean layers , @Switch ( name = 's' , desc = " TODO " ) boolean dontSmooth , InjectedValueAccess context ) throws WorldEditException , FileNotFoundException {
2019-10-23 04:23:52 +00:00
terrainBrush ( session , radius , image , rotation , yscale , false , randomRotate , layers , ! dontSmooth , ScalableHeightMap . Shape . CONE , context ) ;
2014-04-03 02:08:50 +00:00
}
2018-08-12 14:03:07 +00:00
2014-04-03 02:08:50 +00:00
@Command (
2019-07-17 05:43:18 +00:00
name = " cliff " ,
aliases = { " flatcylinder " } ,
2018-08-12 14:03:07 +00:00
desc = " Cliff brush " ,
2019-07-23 02:22:32 +00:00
descFooter = " This brush flattens terrain and creates cliffs. "
2018-08-12 14:03:07 +00:00
)
@CommandPermissions ( " worldedit.brush.height " )
2019-10-23 04:23:52 +00:00
public void cliffBrush ( LocalSession session ,
2019-11-11 21:02:28 +00:00
@Arg ( desc = " Expression " , def = " 5 " )
2019-08-15 19:21:24 +00:00
Expression radius ,
2019-11-11 21:02:28 +00:00
@Arg ( desc = " String " , def = " " )
2019-07-23 02:22:32 +00:00
String image ,
@Arg ( def = " 0 " , desc = " rotation " ) @Step ( 90 ) @Range ( min = 0 , max = 360 )
int rotation ,
2019-11-11 21:02:28 +00:00
@Arg ( desc = " double " , def = " 1 " )
2019-07-23 02:22:32 +00:00
double yscale ,
@Switch ( name = 'r' , desc = " Enables random off-axis rotation " )
boolean randomRotate ,
@Switch ( name = 'l' , desc = " Will work on snow layers " )
boolean layers ,
@Switch ( name = 's' , desc = " Disables smoothing " )
boolean dontSmooth , InjectedValueAccess context ) throws WorldEditException , FileNotFoundException {
2019-10-23 04:23:52 +00:00
terrainBrush ( session , radius , image , rotation , yscale , true , randomRotate , layers , ! dontSmooth , ScalableHeightMap . Shape . CYLINDER , context ) ;
2018-08-12 14:03:07 +00:00
}
@Command (
2019-07-17 05:43:18 +00:00
name = " flatten " ,
aliases = { " flatmap " , " flat " } ,
2019-07-06 00:46:48 +00:00
desc = " This brush raises or lowers land towards the clicked point "
2018-08-12 14:03:07 +00:00
)
@CommandPermissions ( " worldedit.brush.height " )
2019-11-11 21:02:28 +00:00
public void flattenBrush ( LocalSession session , @Arg ( desc = " Expression " , def = " 5 " ) Expression radius , @Arg ( desc = " String " , def = " " ) String image , @Arg ( def = " 0 " , desc = " rotation " ) @Step ( 90 ) @Range ( min = 0 , max = 360 ) int rotation , @Arg ( desc = " double " , def = " 1 " ) double yscale ,
2019-07-23 02:22:32 +00:00
@Switch ( name = 'r' , desc = " Enables random off-axis rotation " )
2019-07-22 02:49:08 +00:00
boolean randomRotate ,
2019-07-23 02:22:32 +00:00
@Switch ( name = 'l' , desc = " Will work on snow layers " )
2019-07-22 02:49:08 +00:00
boolean layers ,
2019-07-23 02:22:32 +00:00
@Switch ( name = 's' , desc = " Disables smoothing " )
2019-07-22 02:49:08 +00:00
boolean dontSmooth , InjectedValueAccess context ) throws WorldEditException , FileNotFoundException {
2019-10-23 04:23:52 +00:00
terrainBrush ( session , radius , image , rotation , yscale , true , randomRotate , layers , ! dontSmooth , ScalableHeightMap . Shape . CONE , context ) ;
2018-08-12 14:03:07 +00:00
}
2019-10-23 04:23:52 +00:00
private void terrainBrush ( LocalSession session ,
2019-11-11 21:02:28 +00:00
@Arg ( desc = " Expression " ) Expression radius , String image , int rotation ,
2019-09-21 01:52:35 +00:00
double yscale , boolean flat , boolean randomRotate , boolean layers , boolean smooth ,
2019-10-23 04:23:52 +00:00
Shape shape , InjectedValueAccess context ) throws WorldEditException , FileNotFoundException {
2019-07-06 00:46:48 +00:00
worldEdit . checkMaxBrushRadius ( radius ) ;
2018-08-12 14:03:07 +00:00
InputStream stream = getHeightmapStream ( image ) ;
HeightBrush brush ;
if ( flat ) {
try {
2018-09-07 17:11:56 +00:00
brush = new FlattenBrush ( stream , rotation , yscale , layers , smooth , " #clipboard " . equalsIgnoreCase ( image ) ? session . getClipboard ( ) . getClipboard ( ) : null , shape ) ;
2018-08-12 14:03:07 +00:00
} catch ( EmptyClipboardException ignore ) {
brush = new FlattenBrush ( stream , rotation , yscale , layers , smooth , null , shape ) ;
}
} else {
try {
2018-09-07 17:11:56 +00:00
brush = new HeightBrush ( stream , rotation , yscale , layers , smooth , " #clipboard " . equalsIgnoreCase ( image ) ? session . getClipboard ( ) . getClipboard ( ) : null ) ;
2018-08-12 14:03:07 +00:00
} catch ( EmptyClipboardException ignore ) {
brush = new HeightBrush ( stream , rotation , yscale , layers , smooth , null ) ;
}
}
if ( randomRotate ) {
brush . setRandomRotate ( true ) ;
}
2019-10-23 04:23:52 +00:00
set ( context ,
2019-08-26 04:45:03 +00:00
brush )
. setSize ( radius ) ;
2018-08-12 14:03:07 +00:00
}
2019-07-21 11:39:36 +00:00
private InputStream getHeightmapStream ( String filename ) throws FileNotFoundException {
2018-09-07 17:11:56 +00:00
if ( filename = = null ) return null ;
2019-07-22 02:49:08 +00:00
String filenamePng = filename . endsWith ( " .png " ) ? filename : filename + " .png " ;
2018-08-12 14:03:07 +00:00
File file = new File ( Fawe . imp ( ) . getDirectory ( ) , Settings . IMP . PATHS . HEIGHTMAP + File . separator + filenamePng ) ;
2018-09-02 21:46:35 +00:00
if ( file . exists ( ) ) return new FileInputStream ( file ) ;
URI uri = ImageUtil . getImageURI ( filename ) ;
return ImageUtil . getInputStream ( uri ) ;
2018-08-12 14:03:07 +00:00
}
@Command (
2019-07-17 05:43:18 +00:00
name = " copypaste " ,
2019-08-26 04:45:03 +00:00
aliases = { " cp " , " copypasta " } ,
2018-08-12 14:03:07 +00:00
desc = " Copy Paste brush " ,
2019-07-17 05:43:18 +00:00
descFooter = " Left click the base of an object to copy. \ n " +
2019-07-06 00:46:48 +00:00
" Right click to paste \ n " +
" Note: Works well with the clipboard scroll action \ n " +
" Video: https://www.youtube.com/watch?v=RPZIaTbqoZw "
2018-08-12 14:03:07 +00:00
)
@CommandPermissions ( " worldedit.brush.copy " )
2019-10-23 04:23:52 +00:00
public void copy ( Player player , LocalSession session , InjectedValueAccess context ,
2019-11-11 21:02:28 +00:00
@Arg ( desc = " Expression " , def = " 5 " ) Expression radius ,
2019-09-21 01:52:35 +00:00
@Switch ( name = 'r' , desc = " Apply random rotation on paste " ) boolean randomRotate ,
@Switch ( name = 'a' , desc = " Apply auto view based rotation on paste " ) boolean autoRotate ) throws WorldEditException {
2019-08-15 19:21:24 +00:00
worldEdit . checkMaxBrushRadius ( radius ) ;
player . print ( BBC . BRUSH_COPY . format ( radius ) ) ;
2018-08-12 14:03:07 +00:00
2019-10-23 04:23:52 +00:00
set ( context ,
2019-09-21 01:52:35 +00:00
new CopyPastaBrush ( player , session , randomRotate , autoRotate ) )
2019-08-15 19:21:24 +00:00
. setSize ( radius ) ;
2018-08-12 14:03:07 +00:00
}
@Command (
2019-07-17 05:43:18 +00:00
name = " command " ,
aliases = { " cmd " } ,
2018-08-12 14:03:07 +00:00
desc = " Command brush " ,
2019-07-17 05:43:18 +00:00
descFooter = " Run the commands at the clicked position. \ n " +
2019-07-06 00:46:48 +00:00
" - Your selection will be expanded to the specified size around each point \ n " +
" - Placeholders: {x}, {y}, {z}, {world}, {size} "
2018-08-12 14:03:07 +00:00
)
@CommandPermissions ( " worldedit.brush.command " )
2019-10-23 04:23:52 +00:00
public void command ( InjectedValueAccess context ,
2019-11-11 21:02:28 +00:00
@Arg ( desc = " Expression " ) Expression radius ,
2019-09-21 01:52:35 +00:00
@Arg ( desc = " Command to run " ) List < String > input ) throws WorldEditException {
2019-07-21 11:39:36 +00:00
worldEdit . checkMaxBrushRadius ( radius ) ;
String cmd = StringMan . join ( input , " " ) ;
2019-10-23 04:23:52 +00:00
set ( context ,
2019-09-21 01:52:35 +00:00
new CommandBrush ( cmd ) )
2019-07-21 11:39:36 +00:00
. setSize ( radius ) ;
2019-07-06 00:46:48 +00:00
}
@Command (
name = " butcher " ,
aliases = { " kill " } ,
desc = " Butcher brush, kills mobs within a radius "
2014-04-03 02:08:50 +00:00
)
@CommandPermissions ( " worldedit.brush.butcher " )
2019-10-23 04:23:52 +00:00
public void butcherBrush ( Player player ,
2019-09-21 01:52:35 +00:00
@Arg ( desc = " Radius to kill mobs in " , def = " 5 " )
Expression radius ,
@Switch ( name = 'p' , desc = " Also kill pets " )
boolean killPets ,
@Switch ( name = 'n' , desc = " Also kill NPCs " )
boolean killNpcs ,
@Switch ( name = 'g' , desc = " Also kill golems " )
boolean killGolems ,
@Switch ( name = 'a' , desc = " Also kill animals " )
boolean killAnimals ,
@Switch ( name = 'b' , desc = " Also kill ambient mobs " )
boolean killAmbient ,
@Switch ( name = 't' , desc = " Also kill mobs with name tags " )
boolean killWithName ,
@Switch ( name = 'f' , desc = " Also kill all friendly mobs (Applies the flags `-abgnpt`) " )
boolean killFriendly ,
@Switch ( name = 'r' , desc = " Also destroy armor stands " )
2019-10-23 04:23:52 +00:00
boolean killArmorStands ,
InjectedValueAccess context ) throws WorldEditException {
2019-08-15 19:21:24 +00:00
worldEdit . checkMaxBrushRadius ( radius ) ;
2014-04-03 02:08:50 +00:00
2014-07-16 02:47:47 +00:00
CreatureButcher flags = new CreatureButcher ( player ) ;
2019-07-06 00:46:48 +00:00
flags . or ( CreatureButcher . Flags . FRIENDLY , killFriendly ) ; // No permission check here. Flags will instead be filtered by the subsequent calls.
flags . or ( CreatureButcher . Flags . PETS , killPets , " worldedit.butcher.pets " ) ;
flags . or ( CreatureButcher . Flags . NPCS , killNpcs , " worldedit.butcher.npcs " ) ;
flags . or ( CreatureButcher . Flags . GOLEMS , killGolems , " worldedit.butcher.golems " ) ;
flags . or ( CreatureButcher . Flags . ANIMALS , killAnimals , " worldedit.butcher.animals " ) ;
flags . or ( CreatureButcher . Flags . AMBIENT , killAmbient , " worldedit.butcher.ambient " ) ;
flags . or ( CreatureButcher . Flags . TAGGED , killWithName , " worldedit.butcher.tagged " ) ;
flags . or ( CreatureButcher . Flags . ARMOR_STAND , killArmorStands , " worldedit.butcher.armorstands " ) ;
2019-10-23 04:23:52 +00:00
set ( context , new ButcherBrush ( flags ) ) . setSize ( radius ) ;
2018-08-12 14:03:07 +00:00
}
2014-04-03 02:08:50 +00:00
2019-10-23 04:23:52 +00:00
public BrushSettings process ( Player player , Arguments arguments , BrushSettings settings ) throws WorldEditException {
LocalSession session = worldEdit . getSessionManager ( ) . get ( player ) ;
session . setTool ( player , null ) ;
BrushTool tool = session . getBrushTool ( player ) ;
2019-07-06 00:46:48 +00:00
if ( tool ! = null ) {
tool . setPrimary ( settings ) ;
tool . setSecondary ( settings ) ;
2019-10-23 04:23:52 +00:00
BBC . BRUSH_EQUIPPED . send ( player , arguments . get ( ) . split ( " " ) [ 1 ] ) ;
2019-07-06 00:46:48 +00:00
}
2019-10-23 04:23:52 +00:00
return settings ;
2019-07-06 00:46:48 +00:00
}
2018-08-12 16:36:39 +00:00
2019-10-23 04:23:52 +00:00
public BrushSettings set ( InjectedValueAccess context , Brush brush ) throws InvalidToolBindException {
Player player = context . injectedValue ( Key . of ( Player . class ) ) . orElseThrow ( ( ) - > new IllegalStateException ( " No player " ) ) ;
LocalSession session = player . getSession ( ) ;
2019-07-21 11:39:36 +00:00
BrushSettings bs = new BrushSettings ( ) ;
2019-09-21 01:52:35 +00:00
BrushTool tool = session . getBrushTool ( player , false ) ;
2019-07-21 11:39:36 +00:00
if ( tool ! = null ) {
BrushSettings currentContext = tool . getContext ( ) ;
if ( currentContext ! = null ) {
Brush currentBrush = currentContext . getBrush ( ) ;
if ( currentBrush ! = null & & currentBrush . getClass ( ) = = brush . getClass ( ) ) {
bs = currentContext ;
}
}
}
2019-10-23 04:23:52 +00:00
Arguments arguments = context . injectedValue ( Key . of ( Arguments . class ) ) . orElse ( null ) ;
if ( arguments ! = null ) {
String args = arguments . get ( ) ;
bs . addSetting ( BrushSettings . SettingType . BRUSH , args . substring ( args . indexOf ( ' ' ) + 1 ) ) ;
}
CommandPermissions perms = context . injectedValue ( Key . of ( CommandPermissions . class ) ) . orElse ( null ) ;
if ( perms ! = null ) {
bs . addPermissions ( perms . value ( ) ) ;
}
bs . setBrush ( brush ) ;
return process ( player , arguments , bs ) ;
2019-07-21 11:39:36 +00:00
}
2019-07-22 02:49:08 +00:00
@Command (
name = " forest " ,
desc = " Forest brush, creates a forest in the area "
)
@CommandPermissions ( " worldedit.brush.forest " )
public void forest ( Player player , LocalSession localSession ,
2019-09-21 01:52:35 +00:00
@Arg ( desc = " The shape of the region " )
RegionFactory shape ,
@Arg ( desc = " The size of the brush " , def = " 5 " )
Expression radius ,
@Arg ( desc = " The density of the brush " , def = " 20 " )
double density ,
@Arg ( desc = " The type of tree to use " )
TreeGenerator . TreeType type ) throws WorldEditException , EvaluationException {
2019-08-15 19:21:24 +00:00
setOperationBasedBrush ( player , localSession , radius ,
2019-07-22 02:49:08 +00:00
new Paint ( new TreeGeneratorFactory ( type ) , density / 100 ) , shape , " worldedit.brush.forest " ) ;
}
@Command (
name = " raise " ,
desc = " Raise brush, raise all blocks by one "
)
@CommandPermissions ( " worldedit.brush.raise " )
public void raise ( Player player , LocalSession localSession ,
@Arg ( desc = " The shape of the region " )
RegionFactory shape ,
@Arg ( desc = " The size of the brush " , def = " 5 " )
2019-08-15 19:21:24 +00:00
Expression radius ) throws WorldEditException , EvaluationException {
setOperationBasedBrush ( player , localSession , radius ,
2019-07-22 02:49:08 +00:00
new Deform ( " y-=1 " ) , shape , " worldedit.brush.raise " ) ;
}
@Command (
name = " lower " ,
desc = " Lower brush, lower all blocks by one "
)
@CommandPermissions ( " worldedit.brush.lower " )
public void lower ( Player player , LocalSession localSession ,
@Arg ( desc = " The shape of the region " )
RegionFactory shape ,
@Arg ( desc = " The size of the brush " , def = " 5 " )
2019-09-21 01:52:35 +00:00
Expression radius ) throws WorldEditException , EvaluationException {
2019-08-15 19:21:24 +00:00
setOperationBasedBrush ( player , localSession , radius ,
2019-07-22 02:49:08 +00:00
new Deform ( " y+=1 " ) , shape , " worldedit.brush.lower " ) ;
}
2019-08-29 12:57:03 +00:00
@Command (
name = " savebrush " ,
aliases = { " save " } ,
desc = " Save your current brush "
)
@CommandPermissions ( " worldedit.brush.save " )
public void saveBrush ( Player player , LocalSession session , String name ,
@Switch ( name = 'g' , desc = " Save the brush globally " ) boolean root ) throws WorldEditException , IOException {
BrushTool tool = session . getBrushTool ( player ) ;
if ( tool ! = null ) {
root | = name . startsWith ( " ../ " ) ;
name = FileSystems . getDefault ( ) . getPath ( name ) . getFileName ( ) . toString ( ) ;
File folder = MainUtil . getFile ( Fawe . imp ( ) . getDirectory ( ) , " brushes " ) ;
name = name . endsWith ( " .jsgz " ) ? name : name + " .jsgz " ;
File file ;
if ( root & & player . hasPermission ( " worldedit.brush.save.other " ) ) {
file = new File ( folder , name ) ;
} else {
file = new File ( folder , player . getUniqueId ( ) + File . separator + name ) ;
}
File parent = file . getParentFile ( ) ;
if ( ! parent . exists ( ) ) {
parent . mkdirs ( ) ;
}
file . createNewFile ( ) ;
try ( DataOutputStream out = new DataOutputStream (
new PGZIPOutputStream ( new FileOutputStream ( file ) ) ) ) {
out . writeUTF ( tool . toString ( ) ) ;
} catch ( Throwable e ) {
e . printStackTrace ( ) ;
}
BBC . SCHEMATIC_SAVED . send ( player , name ) ;
} else {
2019-11-02 19:53:25 +00:00
player . printError ( BBC . BRUSH_NONE . s ( ) ) ;
2019-08-29 12:57:03 +00:00
}
}
@Command (
name = " loadbrush " ,
aliases = { " load " } ,
desc = " Load a brush "
)
@CommandPermissions ( " worldedit.brush.load " )
public void loadBrush ( Player player , LocalSession session , String name )
throws WorldEditException , IOException {
name = FileSystems . getDefault ( ) . getPath ( name ) . getFileName ( ) . toString ( ) ;
File folder = MainUtil . getFile ( Fawe . imp ( ) . getDirectory ( ) , " brushes " ) ;
name = name . endsWith ( " .jsgz " ) ? name : name + " .jsgz " ;
File file = new File ( folder , player . getUniqueId ( ) + File . separator + name ) ;
if ( ! file . exists ( ) ) {
file = new File ( folder , name ) ;
}
if ( ! file . exists ( ) ) {
File [ ] files = folder . listFiles ( pathname - > false ) ;
BBC . BRUSH_NOT_FOUND . send ( player , name ) ;
return ;
}
try ( DataInputStream in = new DataInputStream (
new GZIPInputStream ( new FileInputStream ( file ) ) ) ) {
String json = in . readUTF ( ) ;
BrushTool tool = BrushTool . fromString ( player , session , json ) ;
BaseItem item = player . getItemInHand ( HandSide . MAIN_HAND ) ;
session . setTool ( item , tool , player ) ;
BBC . BRUSH_EQUIPPED . send ( player , name ) ;
} catch ( Throwable e ) {
e . printStackTrace ( ) ;
2019-11-02 19:53:25 +00:00
player . printError ( BBC . BRUSH_INCOMPATIBLE . s ( ) ) ;
2019-08-29 12:57:03 +00:00
}
}
@Command (
name = " /listbrush " ,
desc = " List saved brushes " ,
descFooter = " List all brushes in the brush directory "
)
@CommandPermissions ( " worldedit.brush.list " )
public void list ( Actor actor , InjectedValueAccess args ,
@ArgFlag ( name = 'p' , desc = " Prints the requested page " , def = " 0 " )
int page ) throws WorldEditException {
String baseCmd = " /brush loadbrush " ;
File dir = MainUtil . getFile ( Fawe . imp ( ) . getDirectory ( ) , " brushes " ) ;
// TODO NOT IMPLEMENTED
// UtilityCommands.list(dir, actor, args, page, null, true, baseCmd);
}
2019-08-06 20:18:44 +00:00
static void setOperationBasedBrush ( Player player , LocalSession session , Expression radius ,
2019-07-22 02:49:08 +00:00
Contextual < ? extends Operation > factory ,
RegionFactory shape ,
String permission ) throws WorldEditException {
WorldEdit . getInstance ( ) . checkMaxBrushRadius ( radius ) ;
BrushTool tool = session . getBrushTool ( player . getItemInHand ( HandSide . MAIN_HAND ) . getType ( ) ) ;
tool . setSize ( radius ) ;
tool . setFill ( null ) ;
tool . setBrush ( new OperationFactoryBrush ( factory , shape , session ) , permission ) ;
player . print ( " Set brush to " + factory ) ;
}
2014-04-03 02:08:50 +00:00
}