mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-01 02:46:41 +00:00
More work on getting commands to compile
This commit is contained in:
@ -19,6 +19,8 @@
|
||||
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.command.FawePrimitiveBinding;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
@ -65,6 +67,7 @@ import com.sk89q.worldedit.EmptyClipboardException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.command.factory.TreeGeneratorFactory;
|
||||
import com.sk89q.worldedit.command.tool.BrushTool;
|
||||
import com.sk89q.worldedit.command.tool.InvalidToolBindException;
|
||||
import com.sk89q.worldedit.command.tool.brush.Brush;
|
||||
@ -74,6 +77,7 @@ 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;
|
||||
import com.sk89q.worldedit.command.tool.brush.OperationFactoryBrush;
|
||||
import com.sk89q.worldedit.command.tool.brush.SmoothBrush;
|
||||
import com.sk89q.worldedit.command.tool.brush.SphereBrush;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||
@ -83,28 +87,27 @@ import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
||||
import com.sk89q.worldedit.function.Contextual;
|
||||
import com.sk89q.worldedit.function.factory.Deform;
|
||||
import com.sk89q.worldedit.function.factory.Paint;
|
||||
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.SingleBlockTypeMask;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.internal.annotation.Range;
|
||||
import com.sk89q.worldedit.internal.expression.Expression;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.regions.factory.RegionFactory;
|
||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
import com.sk89q.worldedit.world.block.BlockID;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
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;
|
||||
import org.enginehub.piston.inject.Key;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@ -113,9 +116,13 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
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;
|
||||
import org.enginehub.piston.inject.Key;
|
||||
|
||||
/**
|
||||
* Commands to set brush shape.
|
||||
@ -191,13 +198,15 @@ public class BrushCommands extends MethodCommands {
|
||||
aliases = {"recurse", "r"},
|
||||
desc = "Set all connected blocks",
|
||||
descFooter = "Set all connected blocks\n" +
|
||||
"The -d flag Will apply in depth first order\n" +
|
||||
"Note: Set a mask to recurse along specific blocks"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.recursive")
|
||||
public BrushSettings recursiveBrush(Player player, LocalSession session, EditSession editSession, Pattern fill,
|
||||
@Arg(desc = "The radius to sample for blending", def = "5")
|
||||
Expression radius, @Switch(name='d', desc = "TODO") boolean depthFirst, InjectedValueAccess context) throws WorldEditException {
|
||||
Expression radius,
|
||||
@Switch(name='d', desc = "Apply in depth first order")
|
||||
boolean depthFirst,
|
||||
InjectedValueAccess context) throws WorldEditException {
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
return set(session, context,
|
||||
new RecurseBrush(depthFirst))
|
||||
@ -210,15 +219,17 @@ public class BrushCommands extends MethodCommands {
|
||||
name = "line",
|
||||
aliases = {"l"},
|
||||
desc = "Create lines",
|
||||
descFooter = "Create lines.\n" +
|
||||
"The -h flag creates only a shell\n" +
|
||||
"The -s flag selects the clicked point after drawing\n" +
|
||||
"The -f flag creates a flat line"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.line")
|
||||
public BrushSettings lineBrush(Player player, LocalSession session, Pattern fill,
|
||||
@Arg(desc = "The radius to sample for blending", def = "0")
|
||||
Expression radius, @Switch(name='h', desc = "TODO") boolean shell, @Switch(name='s', desc = "TODO") boolean select, @Switch(name='f', desc = "TODO") boolean flat, InjectedValueAccess context) throws WorldEditException {
|
||||
Expression radius,
|
||||
@Switch(name='h', desc = "Create only a shell")
|
||||
boolean shell,
|
||||
@Switch(name='s', desc = "Selects the clicked point after drawing")
|
||||
boolean select,
|
||||
@Switch(name='f', desc = "Create a flat line")
|
||||
boolean flat, InjectedValueAccess context) throws WorldEditException {
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
return set(session, context,
|
||||
new LineBrush(shell, select, flat))
|
||||
@ -265,17 +276,19 @@ public class BrushCommands extends MethodCommands {
|
||||
@Command(
|
||||
name = "catenary",
|
||||
aliases = {"cat", "gravityline", "saggedline"},
|
||||
desc = "Create a hanging line between two points",
|
||||
descFooter = "Create a hanging line between two points.\n" +
|
||||
"The lengthFactor controls how long the line is\n" +
|
||||
"The -h flag creates only a shell\n" +
|
||||
"The -s flag selects the clicked point after drawing\n" +
|
||||
"The -d flag sags the catenary toward the facing direction\n"
|
||||
desc = "Create a hanging line between two points"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.spline")
|
||||
public BrushSettings catenaryBrush(LocalSession session, Pattern fill, @Arg(def = "1.2", desc = "Length of wire compared to distance between points") @Range(min=1) double lengthFactor,
|
||||
@Arg(desc = "The radius to sample for blending", def = "0")
|
||||
Expression radius, @Switch(name='h', desc = "TODO") boolean shell, @Switch(name='s', desc = "TODO") boolean select, @Switch(name='d', desc = "TODO") boolean facingDirection, InjectedValueAccess context) throws WorldEditException {
|
||||
Expression radius,
|
||||
@Switch(name='h', desc = "Create only a shell")
|
||||
boolean shell,
|
||||
@Switch(name='s', desc = "Select the clicked point after drawing")
|
||||
boolean select,
|
||||
@Switch(name='d', desc = "sags the catenary toward the facing direction")
|
||||
boolean facingDirection,
|
||||
InjectedValueAccess context) throws WorldEditException {
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
Brush brush = new CatenaryBrush(shell, select, facingDirection, lengthFactor);
|
||||
return set(session, context,
|
||||
@ -384,18 +397,16 @@ public class BrushCommands extends MethodCommands {
|
||||
@Command(
|
||||
name = "stencil",
|
||||
desc = "Use a height map to paint a surface",
|
||||
descFooter = "Use a height map to paint any surface.\n" +
|
||||
"The -w flag will only apply at maximum saturation\n" +
|
||||
"The -r flag will apply random rotation"
|
||||
descFooter = "Use a height map to paint any surface.\n"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.stencil")
|
||||
public BrushSettings stencilBrush(Player player, LocalSession session, Pattern fill,
|
||||
@Arg(name = "radius", desc = "Expression", def = "5") Expression radius,
|
||||
@Arg(name = "image", desc = "String", def = "") String image,
|
||||
@Arg(def = "0", desc = "rotation") @Step(90) @Range(min=0, max=360) final int rotation,
|
||||
@Arg(name = "yscale", desc = "double", def = "1") final double yscale,
|
||||
@Switch(name='w', desc = "TODO") boolean onlyWhite,
|
||||
@Switch(name='r', desc = "TODO") boolean randomRotate,
|
||||
@Arg(def = "0", desc = "rotation") @Range(min=0, max=360) int rotation,
|
||||
@Arg(name = "yscale", desc = "double", def = "1") double yscale,
|
||||
@Switch(name='w', desc = "Apply at maximum saturation") boolean onlyWhite,
|
||||
@Switch(name='r', desc = "Apply random rotation") boolean randomRotate,
|
||||
InjectedValueAccess context) throws WorldEditException, FileNotFoundException {
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
InputStream stream = getHeightmapStream(image);
|
||||
@ -418,16 +429,13 @@ public class BrushCommands extends MethodCommands {
|
||||
name = "image",
|
||||
aliases = {"color"},
|
||||
desc = "Use a height map to paint a surface",
|
||||
descFooter = "Use a height map to paint any surface.\n" +
|
||||
"The -a flag will use image alpha\n" +
|
||||
"The -f blends the image with the existing terrain"
|
||||
)
|
||||
descFooter = "Use a height map to paint any surface.\n")
|
||||
@CommandPermissions("worldedit.brush.stencil")
|
||||
public BrushSettings imageBrush(LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius,
|
||||
FawePrimitiveBinding.ImageUri imageUri,
|
||||
@Arg(def = "1", desc = "scale height") @Range(min=Double.MIN_NORMAL) final double yscale,
|
||||
@Switch(name='a', desc = "TODO") boolean alpha,
|
||||
@Switch(name='f', desc = "TODO") boolean fadeOut,
|
||||
@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,
|
||||
InjectedValueAccess context) throws WorldEditException, IOException {
|
||||
BufferedImage image = imageUri.load();
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
@ -454,7 +462,10 @@ public class BrushCommands extends MethodCommands {
|
||||
"The -r flag will apply random rotation"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.surface")
|
||||
public BrushSettings surfaceBrush(LocalSession session, Pattern fill, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, InjectedValueAccess context) throws WorldEditException {
|
||||
public BrushSettings surfaceBrush(LocalSession session, Pattern fill,
|
||||
@Arg(name = "radius", desc = "Expression", def = "5")
|
||||
Expression radius,
|
||||
InjectedValueAccess context) throws WorldEditException {
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
return set(session, context, new SurfaceSphereBrush()).setFill(fill).setSize(radius);
|
||||
}
|
||||
@ -504,8 +515,7 @@ public class BrushCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
return set(session, context,
|
||||
new PopulateSchem(mask, holders, (int) density, rotate))
|
||||
.setSize(radius);
|
||||
new PopulateSchem(mask, holders, (int) density, rotate)).setSize(radius);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@ -521,9 +531,7 @@ public class BrushCommands extends MethodCommands {
|
||||
@CommandPermissions("worldedit.brush.layer")
|
||||
public BrushSettings surfaceLayer(LocalSession session, Expression radius, List<BlockState> layers, InjectedValueAccess context) throws WorldEditException {
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
return set(session, context,
|
||||
new LayerBrush(layers.toArray(new BlockState[0])))
|
||||
.setSize(radius);
|
||||
return set(session, context, new LayerBrush(layers.toArray(new BlockState[0]))).setSize(radius);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -537,10 +545,7 @@ public class BrushCommands extends MethodCommands {
|
||||
@CommandPermissions("worldedit.brush.splatter")
|
||||
public BrushSettings splatterBrush(LocalSession session, Pattern fill, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Arg(name = "points", desc = "double", def = "1") double points, @Arg(name = "recursion", desc = "double", def = "5") double recursion, @Arg(name = "solid", desc = "boolean", def = "true") boolean solid, InjectedValueAccess context) throws WorldEditException {
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
return set(session, context,
|
||||
new SplatterBrush((int) points, (int) recursion, solid))
|
||||
.setSize(radius)
|
||||
.setFill(fill);
|
||||
return set(session, context, new SplatterBrush((int) points, (int) recursion, solid)).setSize(radius).setFill(fill);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -596,7 +601,6 @@ public class BrushCommands extends MethodCommands {
|
||||
aliases = { "copy" },
|
||||
desc = "Choose the clipboard brush (Recommended: `/br copypaste`)",
|
||||
descFooter = "Chooses the clipboard brush.\n" +
|
||||
"The -a flag makes it not paste air.\n" +
|
||||
"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."
|
||||
@ -700,7 +704,7 @@ public class BrushCommands extends MethodCommands {
|
||||
"Snow Pic: https://i.imgur.com/Hrzn0I4.png"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.height")
|
||||
public BrushSettings heightBrush(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Arg(name = "image", desc = "String", def = "") final String image, @Arg(def = "0", desc = "rotation") @Step(90) @Range(min=0, max=360) final int rotation, @Arg(name = "yscale", desc = "double", def = "1") final 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 {
|
||||
public BrushSettings heightBrush(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Arg(name = "image", desc = "String", def = "") String image, @Arg(def = "0", desc = "rotation") @Range(min=0, max=360) int rotation, @Arg(name = "yscale", 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 {
|
||||
return terrainBrush(player, session, radius, image, rotation, yscale, false, randomRotate, layers, !dontSmooth, ScalableHeightMap.Shape.CONE, context);
|
||||
}
|
||||
|
||||
@ -714,21 +718,23 @@ public class BrushCommands extends MethodCommands {
|
||||
" - The `-s` flag disables smoothing"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.height")
|
||||
public BrushSettings cliffBrush(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Arg(name = "image", desc = "String", def = "") String image, @Arg(def = "0", desc = "rotation") @Step(90) @Range(min=0, max=360) final int rotation, @Arg(name = "yscale", desc = "double", def = "1") final 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 {
|
||||
public BrushSettings cliffBrush(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Arg(name = "image", desc = "String", def = "") String image, @Arg(def = "0", desc = "rotation") @Step(90) @Range(min=0, max=360) int rotation, @Arg(name = "yscale", 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 {
|
||||
return terrainBrush(player, session, radius, image, rotation, yscale, true, randomRotate, layers, !dontSmooth, ScalableHeightMap.Shape.CYLINDER, context);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "flatten",
|
||||
aliases = {"flatmap", "flat"},
|
||||
descFooter = "Flatten brush flattens terrain\n" +
|
||||
" - The `-r` flag enables random off-axis rotation\n" +
|
||||
" - The `-l` flag will work on snow layers\n" +
|
||||
" - The `-s` flag disables smoothing",
|
||||
desc = "This brush raises or lowers land towards the clicked point"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.height")
|
||||
public BrushSettings flattenBrush(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Arg(name = "image", desc = "String", def = "") final String image, @Arg(def = "0", desc = "rotation") @Step(90) @Range(min=0, max=360) final int rotation, @Arg(name = "yscale", desc = "double", def = "1") final 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 {
|
||||
public BrushSettings flattenBrush(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Arg(name = "image", desc = "String", def = "") String image, @Arg(def = "0", desc = "rotation") @Step(90) @Range(min=0, max=360) int rotation, @Arg(name = "yscale", desc = "double", def = "1") 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 {
|
||||
return terrainBrush(player, session, radius, image, rotation, yscale, true, randomRotate, layers, !dontSmooth, ScalableHeightMap.Shape.CONE, context);
|
||||
}
|
||||
|
||||
@ -759,7 +765,7 @@ public class BrushCommands extends MethodCommands {
|
||||
|
||||
private InputStream getHeightmapStream(String filename) throws FileNotFoundException {
|
||||
if (filename == null) return null;
|
||||
String filenamePng = (filename.endsWith(".png") ? filename : filename + ".png");
|
||||
String filenamePng = filename.endsWith(".png") ? filename : filename + ".png";
|
||||
File file = new File(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HEIGHTMAP + File.separator + filenamePng);
|
||||
if (file.exists()) return new FileInputStream(file);
|
||||
URI uri = ImageUtil.getImageURI(filename);
|
||||
@ -773,13 +779,11 @@ public class BrushCommands extends MethodCommands {
|
||||
desc = "Copy Paste brush",
|
||||
descFooter = "Left click the base of an object to copy.\n" +
|
||||
"Right click to paste\n" +
|
||||
"The -r flag Will apply random rotation on paste\n" +
|
||||
"The -a flag Will apply auto view based rotation on paste\n" +
|
||||
"Note: Works well with the clipboard scroll action\n" +
|
||||
"Video: https://www.youtube.com/watch?v=RPZIaTbqoZw"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.copy")
|
||||
public BrushSettings copy(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Switch(name='r', desc = "TODO") boolean randomRotate, @Switch(name='a', desc = "TODO") boolean autoRotate, InjectedValueAccess context) throws WorldEditException {
|
||||
public BrushSettings copy(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Switch(name='r', desc = "Apply random rotation on paste") boolean randomRotate, @Switch(name='a', desc = "Apply auto view based rotation on paste") boolean autoRotate, InjectedValueAccess context) throws WorldEditException {
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
player.print(BBC.BRUSH_COPY.f(radius));
|
||||
|
||||
@ -861,7 +865,8 @@ public class BrushCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
public BrushSettings set(LocalSession session, InjectedValueAccess context, Brush brush) throws InvalidToolBindException {
|
||||
Player plr = context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"));
|
||||
Player plr = context.injectedValue(Key.of(Player.class))
|
||||
.orElseThrow(() -> new IllegalStateException("No player"));
|
||||
BrushSettings bs = new BrushSettings();
|
||||
BrushTool tool = session.getBrushTool(plr, false);
|
||||
if (tool != null) {
|
||||
@ -873,11 +878,65 @@ public class BrushCommands extends MethodCommands {
|
||||
}
|
||||
}
|
||||
}
|
||||
String[] perms = getPermissions(context);
|
||||
bs.addPermissions(perms);
|
||||
String args = getArguments(context);
|
||||
bs.addSetting(BrushSettings.SettingType.BRUSH, args.substring(args.indexOf(' ') + 1));
|
||||
return bs.setBrush(brush);
|
||||
return bs;
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "forest",
|
||||
desc = "Forest brush, creates a forest in the area"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.forest")
|
||||
public void forest(Player player, LocalSession localSession,
|
||||
@Arg(desc = "The shape of the region")
|
||||
RegionFactory shape,
|
||||
@Arg(desc = "The size of the brush", def = "5")
|
||||
double 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 {
|
||||
setOperationBasedBrush(player, localSession, radius,
|
||||
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")
|
||||
double radius) throws WorldEditException {
|
||||
setOperationBasedBrush(player, localSession, radius,
|
||||
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")
|
||||
double radius) throws WorldEditException {
|
||||
setOperationBasedBrush(player, localSession, radius,
|
||||
new Deform("y+=1"), shape, "worldedit.brush.lower");
|
||||
}
|
||||
|
||||
static void setOperationBasedBrush(Player player, LocalSession session, double radius,
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -11,14 +11,17 @@ import com.boydti.fawe.object.extent.ResettableExtent;
|
||||
import com.boydti.fawe.object.io.PGZIPOutputStream;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.blocks.BaseItem;
|
||||
import com.sk89q.worldedit.command.tool.BrushTool;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
@ -30,7 +33,6 @@ import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import com.sk89q.worldedit.internal.annotation.Range;
|
||||
import com.sk89q.worldedit.util.command.parametric.Optional;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
import org.enginehub.piston.annotation.param.Switch;
|
||||
|
||||
@ -48,22 +50,24 @@ import java.util.zip.GZIPInputStream;
|
||||
* Tool commands.
|
||||
*/
|
||||
|
||||
@Command(aliases = {"brush", "br", "/b"}, desc = "Tool commands")
|
||||
public class BrushOptionsCommands extends MethodCommands {
|
||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
public class BrushOptionsCommands {
|
||||
|
||||
public BrushOptionsCommands(WorldEdit we) {
|
||||
super(we);
|
||||
private WorldEdit worldEdit;
|
||||
|
||||
public BrushOptionsCommands(WorldEdit worldEdit) {
|
||||
this.worldEdit = worldEdit;
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "savebrush",
|
||||
aliases = {"save"},
|
||||
desc = "Save your current brush",
|
||||
descFooter = "Save your current brush\n" +
|
||||
"use the -g flag to save globally"
|
||||
)
|
||||
name = "savebrush",
|
||||
aliases = {"save"},
|
||||
desc = "Save your current brush",
|
||||
descFooter = "Save your current brush use the -g flag to save globally"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.save")
|
||||
public void saveBrush(Player player, LocalSession session, String name, @Switch(name='g', desc = "TODO") boolean root) throws WorldEditException, IOException {
|
||||
public void saveBrush(Player player, LocalSession session, String name,
|
||||
@Switch(name = 'g', desc = "TODO") boolean root) throws WorldEditException, IOException {
|
||||
BrushTool tool = session.getBrushTool(player);
|
||||
if (tool != null) {
|
||||
root |= name.startsWith("../");
|
||||
@ -81,7 +85,8 @@ public class BrushOptionsCommands extends MethodCommands {
|
||||
parent.mkdirs();
|
||||
}
|
||||
file.createNewFile();
|
||||
try (DataOutputStream out = new DataOutputStream(new PGZIPOutputStream(new FileOutputStream(file)))) {
|
||||
try (DataOutputStream out = new DataOutputStream(
|
||||
new PGZIPOutputStream(new FileOutputStream(file)))) {
|
||||
out.writeUTF(tool.toString());
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
@ -93,12 +98,13 @@ public class BrushOptionsCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "loadbrush",
|
||||
aliases = {"load"},
|
||||
desc = "load a brush"
|
||||
)
|
||||
name = "loadbrush",
|
||||
aliases = {"load"},
|
||||
desc = "Load a brush"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.load")
|
||||
public void loadBrush(Player player, LocalSession session, String name) throws WorldEditException, IOException {
|
||||
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";
|
||||
@ -107,16 +113,12 @@ public class BrushOptionsCommands extends MethodCommands {
|
||||
file = new File(folder, name);
|
||||
}
|
||||
if (!file.exists()) {
|
||||
File[] files = folder.listFiles(new FileFilter() {
|
||||
@Override
|
||||
public boolean accept(File pathname) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
File[] files = folder.listFiles(pathname -> false);
|
||||
BBC.BRUSH_NOT_FOUND.send(player, name);
|
||||
return;
|
||||
}
|
||||
try (DataInputStream in = new DataInputStream(new GZIPInputStream(new FileInputStream(file)))) {
|
||||
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);
|
||||
@ -129,14 +131,15 @@ public class BrushOptionsCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/listbrush",
|
||||
desc = "List saved brushes",
|
||||
|
||||
descFooter = "List all brushes in the brush directory\n" +
|
||||
" -p <page> prints the requested page\n"
|
||||
name = "/listbrush",
|
||||
desc = "List saved brushes",
|
||||
descFooter = "List all brushes in the brush directory\n" +
|
||||
" -p <page> prints the requested page\n"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.list")
|
||||
public void list(Actor actor, InjectedValueAccess args, @Switch(name='p', desc = "TODO") @Arg(name = "page", desc = "int", def = "1") int page) throws WorldEditException {
|
||||
public void list(Actor actor, InjectedValueAccess args,
|
||||
@Switch(name = 'p', desc = "Prints the requested page")
|
||||
int page) throws WorldEditException {
|
||||
String baseCmd = Commands.getAlias(BrushCommands.class, "brush") + " " + Commands.getAlias(BrushOptionsCommands.class, "loadbrush");
|
||||
File dir = MainUtil.getFile(Fawe.imp().getDirectory(), "brushes");
|
||||
UtilityCommands.list(dir, actor, args, page, null, true, baseCmd);
|
||||
@ -149,25 +152,25 @@ public class BrushOptionsCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "none",
|
||||
aliases = {"/none"},
|
||||
desc = "Unbind a bound tool from your current item"
|
||||
)
|
||||
public void none(Player player, LocalSession session, InjectedValueAccess args) throws WorldEditException {
|
||||
name = "none",
|
||||
aliases = {"/none"},
|
||||
desc = "Unbind a bound tool from your current item"
|
||||
)
|
||||
public void none(Player player, LocalSession session) throws WorldEditException {
|
||||
session.setTool(player, null);
|
||||
BBC.TOOL_NONE.send(player);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/",
|
||||
aliases = {","},
|
||||
desc = "Toggle the super pickaxe function"
|
||||
name = "/",
|
||||
aliases = {","},
|
||||
desc = "Toggle the super pickaxe function"
|
||||
)
|
||||
@CommandPermissions("worldedit.superpickaxe")
|
||||
public void togglePickaxe(Player player, LocalSession session, InjectedValueAccess args) throws WorldEditException {
|
||||
String newState = args.getString(0, null);
|
||||
public void togglePickaxe(Player player, LocalSession session,
|
||||
@Arg(desc = "state", def = "on") String state) throws WorldEditException {
|
||||
if (session.hasSuperPickAxe()) {
|
||||
if ("on".equals(newState)) {
|
||||
if ("on".equals(state)) {
|
||||
BBC.SUPERPICKAXE_ENABLED.send(player);
|
||||
return;
|
||||
}
|
||||
@ -175,7 +178,7 @@ public class BrushOptionsCommands extends MethodCommands {
|
||||
session.disableSuperPickAxe();
|
||||
BBC.SUPERPICKAXE_DISABLED.send(player);
|
||||
} else {
|
||||
if ("off".equals(newState)) {
|
||||
if ("off".equals(state)) {
|
||||
|
||||
BBC.SUPERPICKAXE_DISABLED.send(player);
|
||||
return;
|
||||
@ -186,54 +189,57 @@ public class BrushOptionsCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "primary",
|
||||
desc = "Set the right click brush",
|
||||
descFooter = "Set the right click brush"
|
||||
)
|
||||
name = "primary",
|
||||
desc = "Set the right click brush",
|
||||
descFooter = "Set the right click brush"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.primary")
|
||||
public void primary(Player player, LocalSession session, InjectedValueAccess args) throws WorldEditException {
|
||||
public void primary(Player player, LocalSession session, InjectedValueAccess args)
|
||||
throws WorldEditException {
|
||||
BaseItem item = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
session.setTool(item, null, player);
|
||||
String cmd = "brush " + args.getJoinedStrings(0);
|
||||
CommandEvent event = new CommandEvent(player, cmd);
|
||||
PlatformCommandManager.getInstance().handleCommandOnCurrentThread(event);
|
||||
BrushTool newTool = session.getBrushTool(item.getType(), player, false);
|
||||
BrushTool newTool = session.getBrushTool(item, player, false);
|
||||
if (newTool != null && tool != null) {
|
||||
newTool.setSecondary(tool.getSecondary());
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "secondary",
|
||||
desc = "Set the left click brush",
|
||||
descFooter = "Set the left click brush"
|
||||
)
|
||||
name = "secondary",
|
||||
desc = "Set the left click brush",
|
||||
descFooter = "Set the left click brush"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.secondary")
|
||||
public void secondary(Player player, LocalSession session, InjectedValueAccess args) throws WorldEditException {
|
||||
public void secondary(Player player, LocalSession session, InjectedValueAccess args)
|
||||
throws WorldEditException {
|
||||
BaseItem item = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
session.setTool(item, null, player);
|
||||
String cmd = "brush " + args.getJoinedStrings(0);
|
||||
CommandEvent event = new CommandEvent(player, cmd);
|
||||
PlatformCommandManager.getInstance().handleCommandOnCurrentThread(event);
|
||||
BrushTool newTool = session.getBrushTool(item.getType(), player, false);
|
||||
BrushTool newTool = session.getBrushTool(item, player, false);
|
||||
if (newTool != null && tool != null) {
|
||||
newTool.setPrimary(tool.getPrimary());
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "visualize",
|
||||
aliases = {"visual", "vis"},
|
||||
desc = "Toggle between different visualization modes",
|
||||
descFooter = "Toggle between different visualization modes\n" +
|
||||
"0 = No visualization\n" +
|
||||
"1 = Single block at target position\n" +
|
||||
"2 = Glass showing what blocks will be changed"
|
||||
)
|
||||
name = "visualize",
|
||||
aliases = {"visual", "vis"},
|
||||
desc = "Toggle between different visualization modes",
|
||||
descFooter = "Toggle between different visualization modes\n" +
|
||||
"0 = No visualization\n" +
|
||||
"1 = Single block at target position\n" +
|
||||
"2 = Glass showing what blocks will be changed"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.visualize")
|
||||
public void visual(Player player, LocalSession session, @Range(min = 0, max = 2)int mode) throws WorldEditException {
|
||||
public void visual(Player player, LocalSession session, @Range(min = 0, max = 2) int mode)
|
||||
throws WorldEditException {
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
BBC.BRUSH_NONE.send(player);
|
||||
@ -246,12 +252,13 @@ public class BrushOptionsCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "target",
|
||||
aliases = {"tar"},
|
||||
desc = "Toggle between different target modes"
|
||||
)
|
||||
name = "target",
|
||||
aliases = {"tar"},
|
||||
desc = "Toggle between different target modes"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.target")
|
||||
public void target(Player player, LocalSession session, @Arg(name = "mode", desc = "int", def = "0") int mode) throws WorldEditException {
|
||||
public void target(Player player, LocalSession session,
|
||||
@Arg(name = "mode", desc = "int", def = "0") int mode) throws WorldEditException {
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
BBC.BRUSH_NONE.send(player);
|
||||
@ -264,12 +271,13 @@ public class BrushOptionsCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "targetmask",
|
||||
aliases = {"tarmask", "tm"},
|
||||
desc = "Set the targeting mask"
|
||||
name = "targetmask",
|
||||
aliases = {"tarmask", "tm"},
|
||||
desc = "Set the targeting mask"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.targetmask")
|
||||
public void targetMask(Player player, EditSession editSession, LocalSession session, InjectedValueAccess context) throws WorldEditException {
|
||||
public void targetMask(Player player, EditSession editSession, LocalSession session,
|
||||
InjectedValueAccess context) throws WorldEditException {
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
BBC.BRUSH_NONE.send(player);
|
||||
@ -286,12 +294,13 @@ public class BrushOptionsCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "targetoffset",
|
||||
aliases = {"to"},
|
||||
desc = "Set the targeting mask"
|
||||
name = "targetoffset",
|
||||
aliases = {"to"},
|
||||
desc = "Set the targeting mask"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.targetoffset")
|
||||
public void targetOffset(Player player, EditSession editSession, LocalSession session, int offset) throws WorldEditException {
|
||||
public void targetOffset(Player player, EditSession editSession, LocalSession session,
|
||||
int offset) throws WorldEditException {
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
BBC.BRUSH_NONE.send(player);
|
||||
@ -302,11 +311,15 @@ public class BrushOptionsCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "scroll",
|
||||
desc = "Toggle between different target modes"
|
||||
name = "scroll",
|
||||
desc = "Toggle between different target modes"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.scroll")
|
||||
public void scroll(Player player, EditSession editSession, LocalSession session, @Optional @Switch(name='h', desc = "TODO") boolean offHand, InjectedValueAccess args) throws WorldEditException {
|
||||
public void scroll(Player player, EditSession editSession, LocalSession session,
|
||||
@Switch(name = 'h', desc = "TODO")
|
||||
boolean offHand,
|
||||
@Arg(desc="Target Modes")
|
||||
String modes, InjectedValueAccess args) throws WorldEditException {
|
||||
BrushTool bt = session.getBrushTool(player, false);
|
||||
if (bt == null) {
|
||||
BBC.BRUSH_NONE.send(player);
|
||||
@ -315,23 +328,25 @@ public class BrushOptionsCommands extends MethodCommands {
|
||||
BrushSettings settings = offHand ? bt.getOffHand() : bt.getContext();
|
||||
ScrollAction action = ScrollAction.fromArguments(bt, player, session, args.getJoinedStrings(0), true);
|
||||
settings.setScrollAction(action);
|
||||
if (args.getString(0).equalsIgnoreCase("none")) {
|
||||
if (modes.equalsIgnoreCase("none")) {
|
||||
BBC.BRUSH_SCROLL_ACTION_UNSET.send(player);
|
||||
} else if (action != null) {
|
||||
String full = args.getJoinedStrings(0);
|
||||
settings.addSetting(BrushSettings.SettingType.SCROLL_ACTION, full);
|
||||
BBC.BRUSH_SCROLL_ACTION_SET.send(player, full);
|
||||
settings.addSetting(BrushSettings.SettingType.SCROLL_ACTION, modes);
|
||||
BBC.BRUSH_SCROLL_ACTION_SET.send(player, modes);
|
||||
}
|
||||
bt.update();
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "mask",
|
||||
aliases = {"/mask"},
|
||||
desc = "Set the brush destination mask"
|
||||
name = "mask",
|
||||
aliases = {"/mask"},
|
||||
desc = "Set the brush destination mask"
|
||||
)
|
||||
@CommandPermissions({"worldedit.brush.options.mask", "worldedit.mask.brush"})
|
||||
public void mask(Player player, LocalSession session, EditSession editSession, @Optional @Switch(name='h', desc = "TODO") boolean offHand, InjectedValueAccess context) throws WorldEditException {
|
||||
public void mask(Player player, LocalSession session, EditSession editSession,
|
||||
@Switch(name = 'h', desc = "TODO")
|
||||
boolean offHand, InjectedValueAccess context)
|
||||
throws WorldEditException {
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
player.print(BBC.BRUSH_NONE.f());
|
||||
@ -356,13 +371,16 @@ public class BrushOptionsCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "smask",
|
||||
aliases = {"/smask", "/sourcemask", "sourcemask"},
|
||||
desc = "Set the brush source mask",
|
||||
descFooter = "Set the brush source mask"
|
||||
name = "smask",
|
||||
aliases = {"/smask", "/sourcemask", "sourcemask"},
|
||||
desc = "Set the brush source mask",
|
||||
descFooter = "Set the brush source mask"
|
||||
)
|
||||
@CommandPermissions({"worldedit.brush.options.mask", "worldedit.mask.brush"})
|
||||
public void smask(Player player, LocalSession session, EditSession editSession, @Optional @Switch(name='h', desc = "TODO") boolean offHand, InjectedValueAccess context) throws WorldEditException {
|
||||
public void smask(Player player, LocalSession session, EditSession editSession,
|
||||
@Switch(name = 'h', desc = "TODO")
|
||||
boolean offHand,
|
||||
InjectedValueAccess context) throws WorldEditException {
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
player.print(BBC.BRUSH_NONE.f());
|
||||
@ -378,20 +396,25 @@ public class BrushOptionsCommands extends MethodCommands {
|
||||
parserContext.setWorld(player.getWorld());
|
||||
parserContext.setSession(session);
|
||||
parserContext.setExtent(editSession);
|
||||
Mask mask = worldEdit.getMaskFactory().parseFromInput(context.getJoinedStrings(0), parserContext);
|
||||
Mask mask = worldEdit.getMaskFactory()
|
||||
.parseFromInput(context.getJoinedStrings(0), parserContext);
|
||||
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
|
||||
settings.addSetting(BrushSettings.SettingType.SOURCE_MASK, context.getString(context.argsLength() - 1));
|
||||
settings.addSetting(BrushSettings.SettingType.SOURCE_MASK,
|
||||
context.getString(context.argsLength() - 1));
|
||||
settings.setSourceMask(mask);
|
||||
tool.update();
|
||||
BBC.BRUSH_SOURCE_MASK.send(player);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "transform",
|
||||
desc = "Set the brush transform"
|
||||
name = "transform",
|
||||
desc = "Set the brush transform"
|
||||
)
|
||||
@CommandPermissions({"worldedit.brush.options.transform", "worldedit.transform.brush"})
|
||||
public void transform(Player player, LocalSession session, EditSession editSession, @Optional @Switch(name='h', desc = "TODO") boolean offHand, InjectedValueAccess context) throws WorldEditException {
|
||||
public void transform(Player player, LocalSession session, EditSession editSession,
|
||||
@Switch(name = 'h', desc = "TODO")
|
||||
boolean offHand,
|
||||
InjectedValueAccess context) throws WorldEditException {
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
player.print(BBC.BRUSH_NONE.f());
|
||||
@ -416,12 +439,16 @@ public class BrushOptionsCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "mat",
|
||||
aliases = {"material"},
|
||||
desc = "Set the brush material"
|
||||
)
|
||||
name = "mat",
|
||||
aliases = {"material"},
|
||||
desc = "Set the brush material"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.options.material")
|
||||
public void material(Player player, EditSession editSession, LocalSession session, Pattern pattern, @Switch(name='h', desc = "TODO") boolean offHand, InjectedValueAccess context) throws WorldEditException {
|
||||
public void material(Player player, EditSession editSession, LocalSession session,
|
||||
Pattern pattern,
|
||||
@Switch(name = 'h', desc = "TODO")
|
||||
boolean offHand,
|
||||
InjectedValueAccess context) throws WorldEditException {
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
player.print(BBC.BRUSH_NONE.f());
|
||||
@ -440,12 +467,14 @@ public class BrushOptionsCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "range",
|
||||
desc = "Set the brush range"
|
||||
)
|
||||
name = "range",
|
||||
desc = "Set the brush range"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.options.range")
|
||||
public void range(Player player, LocalSession session, InjectedValueAccess args) throws WorldEditException {
|
||||
int range = Math.max(0, Math.min(256, args.getInteger(0)));
|
||||
public void range(Player player, LocalSession session,
|
||||
@Arg(desc = "Range")
|
||||
int range) throws WorldEditException {
|
||||
range = Math.max(0, Math.min(256, range));
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
player.print(BBC.BRUSH_NONE.f());
|
||||
@ -456,12 +485,15 @@ public class BrushOptionsCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "size",
|
||||
desc = "Set the brush size"
|
||||
)
|
||||
name = "size",
|
||||
desc = "Set the brush size"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.options.size")
|
||||
public void size(Player player, LocalSession session, InjectedValueAccess args, @Switch(name='h', desc = "TODO") boolean offHand) throws WorldEditException {
|
||||
int radius = args.getInteger(0);
|
||||
public void size(Player player, LocalSession session,
|
||||
@Arg(desc = "The size of the brush", def = "5")
|
||||
int radius,
|
||||
@Switch(name = 'h', desc = "TODO")
|
||||
boolean offHand) throws WorldEditException {
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
|
@ -99,14 +99,16 @@ import java.util.zip.ZipOutputStream;
|
||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
public class ClipboardCommands {
|
||||
|
||||
private WorldEdit worldEdit;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param worldEdit reference to WorldEdit
|
||||
*/
|
||||
public ClipboardCommands(WorldEdit worldEdit) {
|
||||
super(worldEdit);
|
||||
checkNotNull(worldEdit);
|
||||
this.worldEdit = worldEdit;
|
||||
}
|
||||
|
||||
|
||||
@ -262,7 +264,7 @@ public class ClipboardCommands {
|
||||
|
||||
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
|
||||
copy.setSourceFunction(new BlockReplace(editSession, leavePattern));
|
||||
copy.setCopyingEntities(copyEntities);
|
||||
copy.setCopyingEntities(!skipEntities);
|
||||
copy.setRemovingEntities(true);
|
||||
copy.setCopyingBiomes(copyBiomes);
|
||||
Mask sourceMask = editSession.getSourceMask();
|
||||
|
@ -19,6 +19,9 @@
|
||||
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION;
|
||||
import static com.sk89q.worldedit.internal.command.CommandUtil.requireIV;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
@ -34,6 +37,7 @@ import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionOperationException;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import java.util.List;
|
||||
import org.enginehub.piston.Command;
|
||||
import org.enginehub.piston.CommandManager;
|
||||
import org.enginehub.piston.CommandManagerService;
|
||||
@ -42,11 +46,6 @@ import org.enginehub.piston.annotation.param.Arg;
|
||||
import org.enginehub.piston.inject.Key;
|
||||
import org.enginehub.piston.part.SubCommandPart;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION;
|
||||
import static com.sk89q.worldedit.internal.command.CommandUtil.requireIV;
|
||||
|
||||
/**
|
||||
* Extracted from {@link SelectionCommands} to allow importing of {@link Command}.
|
||||
*/
|
||||
@ -54,8 +53,8 @@ import static com.sk89q.worldedit.internal.command.CommandUtil.requireIV;
|
||||
public class ExpandCommands {
|
||||
|
||||
public static void register(CommandRegistrationHandler registration,
|
||||
CommandManager commandManager,
|
||||
CommandManagerService commandManagerService) {
|
||||
CommandManager commandManager,
|
||||
CommandManagerService commandManagerService) {
|
||||
// Collect the general expand command
|
||||
CommandManager collect = commandManagerService.newCommandManager();
|
||||
|
||||
@ -121,13 +120,13 @@ public class ExpandCommands {
|
||||
)
|
||||
@Logging(REGION)
|
||||
public void expand(Player player, LocalSession session,
|
||||
@Arg(desc = "Amount to expand the selection by, can be `vert` to expand to the whole vertical column")
|
||||
int amount,
|
||||
@Arg(desc = "Amount to expand the selection by in the other direction", def = "0")
|
||||
int reverseAmount,
|
||||
@Arg(desc = "Direction to expand", def = Direction.AIM)
|
||||
@MultiDirection
|
||||
List<BlockVector3> direction) throws WorldEditException {
|
||||
@Arg(desc = "Amount to expand the selection by, can be `vert` to expand to the whole vertical column")
|
||||
int amount,
|
||||
@Arg(desc = "Amount to expand the selection by in the other direction", def = "0")
|
||||
int reverseAmount,
|
||||
@Arg(desc = "Direction to expand", def = Direction.AIM)
|
||||
@MultiDirection
|
||||
List<BlockVector3> direction) throws WorldEditException {
|
||||
Region region = session.getSelection(player.getWorld());
|
||||
int oldSize = region.getArea();
|
||||
|
||||
|
@ -247,14 +247,14 @@ public class GenerationCommands {
|
||||
@CommandPermissions("worldedit.generation.sphere")
|
||||
@Logging(PLACEMENT)
|
||||
public void sphere(FawePlayer fp, Player player, LocalSession session, EditSession editSession,
|
||||
@Arg(desc = "The pattern of blocks to generate")
|
||||
Pattern pattern,
|
||||
@Arg(desc = "The radii of the sphere. Order is N/S, U/D, E/W")
|
||||
BlockVector3 radii,
|
||||
@Switch(name = 'r', desc = "Raise the bottom of the sphere to the placement position")
|
||||
boolean raised,
|
||||
@Switch(name = 'h', desc = "Make a hollow sphere")
|
||||
boolean hollow) throws WorldEditException {
|
||||
@Arg(desc = "The pattern of blocks to generate")
|
||||
Pattern pattern,
|
||||
@Arg(desc = "The radii of the sphere. Order is N/S, U/D, E/W")
|
||||
BlockVector3 radii,
|
||||
@Switch(name = 'r', desc = "Raise the bottom of the sphere to the placement position")
|
||||
boolean raised,
|
||||
@Switch(name = 'h', desc = "Make a hollow sphere")
|
||||
boolean hollow, InjectedValueAccess context) throws WorldEditException {
|
||||
BlockVector3 pos = session.getPlacementPosition(player);
|
||||
BlockVector3 finalPos = raised ? pos.add(0, radii.getY(), 0) : pos;
|
||||
fp.checkConfirmationRadius(() -> {
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweAPI;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
@ -33,7 +35,6 @@ import com.boydti.fawe.object.changeset.DiskStorageHistory;
|
||||
import com.boydti.fawe.regions.FaweMaskManager;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
@ -41,11 +42,10 @@ import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.internal.annotation.Range;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.internal.annotation.Range;
|
||||
import org.enginehub.piston.annotation.param.Switch;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
@ -53,14 +53,13 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import org.enginehub.piston.annotation.param.Switch;
|
||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
||||
|
||||
/**
|
||||
* Commands to undo, redo, and clear history.
|
||||
*/
|
||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
//@Command(aliases = {}, desc = "Commands to undo, redo, and clear history: [More Info](http://wiki.sk89q.com/wiki/WorldEdit/Features#History)")
|
||||
public class HistoryCommands extends MethodCommands {
|
||||
|
||||
private final WorldEdit worldEdit;
|
||||
@ -83,7 +82,7 @@ public class HistoryCommands extends MethodCommands {
|
||||
" - Import from disk: /frb #import"
|
||||
)
|
||||
@CommandPermissions("worldedit.history.rollback")
|
||||
public void faweRollback(final Player player, LocalSession session, final String user, @Arg(def = "0", desc = "radius") @Range(min = 0) int radius, @Arg(name = "time", desc = "String", def = "0") String time, @Switch(name='r', desc = "TODO") boolean restore) throws WorldEditException {
|
||||
public void faweRollback(Player player, LocalSession session, String user, @Arg(def = "0", desc = "radius") @Range(min = 0) int radius, @Arg(name = "time", desc = "String", def = "0") String time, @Switch(name='r', desc = "TODO") boolean restore) throws WorldEditException {
|
||||
if (!Settings.IMP.HISTORY.USE_DATABASE) {
|
||||
BBC.SETTING_DISABLE.send(player, "history.use-database (Import with /frb #import )");
|
||||
return;
|
||||
@ -209,7 +208,7 @@ public class HistoryCommands extends MethodCommands {
|
||||
" - Import from disk: /frb #import"
|
||||
)
|
||||
@CommandPermissions("worldedit.history.rollback")
|
||||
public void restore(final Player player, LocalSession session, final String user, @Arg(def = "0", desc = "radius") @Range(min = 0) int radius, @Arg(name = "time", desc = "String", def = "0") String time) throws WorldEditException {
|
||||
public void restore(Player player, LocalSession session, String user, @Arg(def = "0", desc = "radius") @Range(min = 0) int radius, @Arg(name = "time", desc = "String", def = "0") String time) throws WorldEditException {
|
||||
faweRollback(player, session, user, radius, time, true);
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,6 @@ package com.sk89q.worldedit.command;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.sk89q.worldedit.command.util.Logging.LogMode.POSITION;
|
||||
|
||||
import com.boydti.fawe.FaweAPI;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
@ -32,7 +31,6 @@ import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.command.util.Logging;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
@ -41,7 +39,6 @@ import org.enginehub.piston.annotation.param.Switch;
|
||||
/**
|
||||
* Commands for moving the player around.
|
||||
*/
|
||||
@Command(aliases = {}, desc = "Commands for moving the player around: [More Info](https://goo.gl/uQTUiT)")
|
||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
public class NavigationCommands {
|
||||
|
||||
|
@ -51,8 +51,7 @@ public class PatternCommands extends MethodCommands {
|
||||
@Command(
|
||||
name = "#existing",
|
||||
aliases = {"#*", "*", ".*"},
|
||||
desc = "Use the block that is already there",
|
||||
usage = "[properties]"
|
||||
desc = "Use the block that is already there"
|
||||
)
|
||||
public Pattern existing(Extent extent, @Arg(name = "properties", desc = "String", def = "") String properties) { // TODO FIXME , @Arg(name = "properties", desc = "String", def = "") String properties
|
||||
if (properties == null) return new ExistingPattern(extent);
|
||||
|
@ -31,18 +31,17 @@ import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweAPI;
|
||||
import com.boydti.fawe.beta.IQueueExtent;
|
||||
import com.boydti.fawe.beta.filters.DistrFilter;
|
||||
import com.boydti.fawe.beta.filters.SetFilter;
|
||||
import com.boydti.fawe.beta.implementation.QueueHandler;
|
||||
import com.boydti.fawe.beta.filters.DistrFilter;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.object.FaweLimit;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.beta.IQueueExtent;
|
||||
import com.boydti.fawe.object.exception.FaweException;
|
||||
import com.boydti.fawe.object.visitor.Fast2DIterator;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
@ -62,6 +61,7 @@ import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.visitor.LayerVisitor;
|
||||
import com.sk89q.worldedit.internal.annotation.Direction;
|
||||
import com.sk89q.worldedit.internal.annotation.Range;
|
||||
import com.sk89q.worldedit.internal.annotation.Selection;
|
||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
@ -78,7 +78,6 @@ import com.sk89q.worldedit.regions.RegionOperationException;
|
||||
import com.sk89q.worldedit.regions.Regions;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
|
||||
import com.sk89q.worldedit.internal.annotation.Range;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
@ -94,11 +93,11 @@ import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
import org.enginehub.piston.annotation.param.Switch;
|
||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
||||
|
||||
/**
|
||||
* Commands that operate on regions.
|
||||
*/
|
||||
//@Command(aliases = {}, desc = "Commands that operate on regions: [More Info](http://wiki.sk89q.com/wiki/WorldEdit/Region_operations)")
|
||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
public class RegionCommands extends MethodCommands {
|
||||
|
||||
@ -114,6 +113,39 @@ public class RegionCommands extends MethodCommands {
|
||||
this.worldEdit = worldEdit;
|
||||
}
|
||||
|
||||
|
||||
@Command(
|
||||
name = "debugtest",
|
||||
desc = "debugtest"
|
||||
)
|
||||
@CommandPermissions("fawe.admin.debug")
|
||||
public void debugtest(Player player, @Selection Region region) throws WorldEditException {
|
||||
QueueHandler queueHandler = Fawe.get().getQueueHandler();
|
||||
World world = player.getWorld();
|
||||
DistrFilter filter = new DistrFilter();
|
||||
long start = System.currentTimeMillis();
|
||||
queueHandler.apply(world, region, filter);
|
||||
long diff = System.currentTimeMillis() - start;
|
||||
System.out.println(diff);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "db2",
|
||||
desc = "db2"
|
||||
)
|
||||
@CommandPermissions("fawe.admin.debug")
|
||||
public void db2(Player player, @Selection Region region, String blockStr) throws WorldEditException {
|
||||
QueueHandler queueHandler = Fawe.get().getQueueHandler();
|
||||
World world = player.getWorld();
|
||||
BlockState block = BlockState.get(blockStr);
|
||||
SetFilter filter = new SetFilter(block);
|
||||
long start = System.currentTimeMillis();
|
||||
queueHandler.apply(world, region, filter);
|
||||
long diff = System.currentTimeMillis() - start;
|
||||
System.out.println(diff);
|
||||
}
|
||||
|
||||
|
||||
@Command(
|
||||
name = "/fixlighting",
|
||||
desc = "Get the light at a position"
|
||||
@ -210,7 +242,7 @@ public class RegionCommands extends MethodCommands {
|
||||
@Selection Region region,
|
||||
@Arg(desc = "The pattern of blocks to place")
|
||||
Pattern pattern,
|
||||
@Range(min = 0) @Arg(desc = "The thickness of the line", def = "0")
|
||||
@Arg(desc = "The thickness of the line", def = "0")
|
||||
int thickness,
|
||||
@Switch(name = 'h', desc = "Generate only a shell")
|
||||
boolean shell) throws WorldEditException {
|
||||
@ -218,6 +250,8 @@ public class RegionCommands extends MethodCommands {
|
||||
player.printError("//line only works with cuboid selections");
|
||||
return 0;
|
||||
}
|
||||
checkCommandArgument(thickness >= 0, "Thickness must be >= 0");
|
||||
|
||||
CuboidRegion cuboidregion = (CuboidRegion) region;
|
||||
BlockVector3 pos1 = cuboidregion.getPos1();
|
||||
BlockVector3 pos2 = cuboidregion.getPos2();
|
||||
@ -235,26 +269,26 @@ public class RegionCommands extends MethodCommands {
|
||||
@CommandPermissions("worldedit.region.curve")
|
||||
@Logging(REGION)
|
||||
public void curve(FawePlayer player, EditSession editSession,
|
||||
@Selection Region region,
|
||||
@Arg(desc = "The pattern of blocks to place")
|
||||
Pattern pattern,
|
||||
@Range(min = 0) @Arg(desc = "The thickness of the curve", def = "0")
|
||||
int thickness,
|
||||
@Switch(name = 'h', desc = "Generate only a shell")
|
||||
boolean shell,
|
||||
InjectedValueAccess context) throws WorldEditException {
|
||||
@Selection Region region,
|
||||
@Arg(desc = "The pattern of blocks to place")
|
||||
Pattern pattern,
|
||||
@Arg(desc = "The thickness of the curve", def = "0")
|
||||
int thickness,
|
||||
@Switch(name = 'h', desc = "Generate only a shell")
|
||||
boolean shell, InjectedValueAccess context) throws WorldEditException {
|
||||
if (!(region instanceof ConvexPolyhedralRegion)) {
|
||||
player.printError("//curve only works with convex polyhedral selections");
|
||||
return;
|
||||
}
|
||||
checkCommandArgument(thickness >= 0, "Thickness must be >= 0");
|
||||
|
||||
player.checkConfirmationRegion(() -> {
|
||||
ConvexPolyhedralRegion cpregion = (ConvexPolyhedralRegion) region;
|
||||
List<BlockVector3> vectors = new ArrayList<>(cpregion.getVertices());
|
||||
|
||||
int blocksChanged = editSession.drawSpline(pattern, vectors, 0, 0, 0, 10, thickness, !shell);
|
||||
int blocksChanged = editSession.drawSpline(pattern, vectors, 0, 0, 0, 10, thickness, !shell);
|
||||
|
||||
BBC.VISITOR_BLOCK.send(player, blocksChanged);
|
||||
BBC.VISITOR_BLOCK.send(player, blocksChanged);
|
||||
}, getArguments(context), region, context);
|
||||
}
|
||||
|
||||
@ -265,12 +299,20 @@ public class RegionCommands extends MethodCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.region.replace")
|
||||
@Logging(REGION)
|
||||
public void replace(FawePlayer player, EditSession editSession, @Selection Region region, @Arg(name = "from", desc = "Mask", def = "") Mask from, Pattern to, InjectedValueAccess context) throws WorldEditException {
|
||||
public void replace(FawePlayer player, EditSession editSession, @Selection Region region,
|
||||
@Arg(desc = "The mask representing blocks to replace", def = "")
|
||||
Mask from,
|
||||
@Arg(desc = "The pattern of blocks to replace with")
|
||||
Pattern to, InjectedValueAccess context) throws WorldEditException {
|
||||
player.checkConfirmationRegion(() -> {
|
||||
int affected = editSession.replaceBlocks(region, from == null ? new ExistingBlockMask(editSession) : from, to);
|
||||
BBC.VISITOR_BLOCK.send(player, affected);
|
||||
if (!player.hasPermission("fawe.tips"))
|
||||
BBC.TIP_REPLACE_ID.or(BBC.TIP_REPLACE_LIGHT, BBC.TIP_REPLACE_MARKER, BBC.TIP_TAB_COMPLETE, BBC.TIP_REPLACE_REGEX, BBC.TIP_REPLACE_REGEX_2, BBC.TIP_REPLACE_REGEX_3, BBC.TIP_REPLACE_REGEX_4, BBC.TIP_REPLACE_REGEX_5).send(player);
|
||||
if (!player.hasPermission("fawe.tips")) {
|
||||
BBC.TIP_REPLACE_ID
|
||||
.or(BBC.TIP_REPLACE_LIGHT, BBC.TIP_REPLACE_MARKER, BBC.TIP_TAB_COMPLETE,
|
||||
BBC.TIP_REPLACE_REGEX, BBC.TIP_REPLACE_REGEX_2, BBC.TIP_REPLACE_REGEX_3,
|
||||
BBC.TIP_REPLACE_REGEX_4, BBC.TIP_REPLACE_REGEX_5).send(player);
|
||||
}
|
||||
}, getArguments(context), region, context);
|
||||
}
|
||||
|
||||
@ -305,8 +347,8 @@ public class RegionCommands extends MethodCommands {
|
||||
@CommandPermissions("worldedit.region.overlay")
|
||||
@Logging(REGION)
|
||||
public void overlay(FawePlayer player, EditSession editSession, @Selection Region region,
|
||||
@Arg(desc = "The pattern of blocks to overlay")
|
||||
Pattern pattern, InjectedValueAccess context) throws WorldEditException {
|
||||
@Arg(desc = "The pattern of blocks to overlay")
|
||||
Pattern pattern, InjectedValueAccess context) throws WorldEditException {
|
||||
player.checkConfirmationRegion(() -> {
|
||||
int affected = editSession.overlayCuboidBlocks(region, pattern);
|
||||
BBC.VISITOR_BLOCK.send(player, affected);
|
||||
@ -339,14 +381,16 @@ public class RegionCommands extends MethodCommands {
|
||||
}, getArguments(context), region, context);
|
||||
}
|
||||
|
||||
@org.enginehub.piston.annotation.Command(
|
||||
@Command(
|
||||
name = "/center",
|
||||
aliases = { "/middle" },
|
||||
desc = "Set the center block(s)"
|
||||
)
|
||||
@Logging(REGION)
|
||||
@CommandPermissions("worldedit.region.center")
|
||||
public void center(Player player, EditSession editSession, @Selection Region region, Pattern pattern) throws WorldEditException {
|
||||
public void center(Player player, EditSession editSession, @Selection Region region,
|
||||
@Arg(desc = "The pattern of blocks to set")
|
||||
Pattern pattern) throws WorldEditException {
|
||||
int affected = editSession.center(region, pattern);
|
||||
BBC.VISITOR_BLOCK.send(player, affected);
|
||||
}
|
||||
@ -370,7 +414,9 @@ public class RegionCommands extends MethodCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.region.walls")
|
||||
@Logging(REGION)
|
||||
public void walls(FawePlayer player, EditSession editSession, @Selection Region region, Pattern pattern, InjectedValueAccess context) throws WorldEditException {
|
||||
public void walls(FawePlayer player, EditSession editSession, @Selection Region region,
|
||||
@Arg(desc = "The pattern of blocks to set")
|
||||
Pattern pattern, InjectedValueAccess context) throws WorldEditException {
|
||||
player.checkConfirmationRegion(() -> {
|
||||
int affected = editSession.makeWalls(region, pattern);
|
||||
BBC.VISITOR_BLOCK.send(player, affected);
|
||||
@ -384,7 +430,9 @@ public class RegionCommands extends MethodCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.region.faces")
|
||||
@Logging(REGION)
|
||||
public void faces(FawePlayer player, EditSession editSession, @Selection Region region, Pattern pattern, InjectedValueAccess context) throws WorldEditException {
|
||||
public void faces(FawePlayer player, EditSession editSession, @Selection Region region,
|
||||
@Arg(desc = "The pattern of blocks to set")
|
||||
Pattern pattern, InjectedValueAccess context) throws WorldEditException {
|
||||
player.checkConfirmationRegion(() -> {
|
||||
int affected = editSession.makeCuboidFaces(region, pattern);
|
||||
BBC.VISITOR_BLOCK.send(player, affected);
|
||||
@ -398,7 +446,12 @@ public class RegionCommands extends MethodCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.region.smooth")
|
||||
@Logging(REGION)
|
||||
public void smooth(FawePlayer player, EditSession editSession, @Selection Region region, @Arg(name = "iterations", desc = "int", def = "1") int iterations, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='s', desc = "TODO") boolean snow, InjectedValueAccess context) throws WorldEditException {
|
||||
public void smooth(FawePlayer player, EditSession editSession, @Selection Region region,
|
||||
@Arg(desc = "# of iterations to perform", def = "1")
|
||||
int iterations,
|
||||
@Arg(desc = "The mask of blocks to use as the height map", def = "")
|
||||
Mask mask,
|
||||
@Switch(name='s', desc = "TODO") boolean snow, InjectedValueAccess context) throws WorldEditException {
|
||||
BlockVector3 min = region.getMinimumPoint();
|
||||
BlockVector3 max = region.getMaximumPoint();
|
||||
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
|
||||
@ -464,24 +517,27 @@ public class RegionCommands extends MethodCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.region.move")
|
||||
@Logging(ORIENTATION_REGION)
|
||||
public void move(FawePlayer player, LocalSession session, EditSession editSession,
|
||||
public void move(FawePlayer player, EditSession editSession, LocalSession session,
|
||||
@Selection Region region,
|
||||
@Arg(desc = "# of blocks to move", def = "1")
|
||||
int count,
|
||||
@Arg(desc = "The direction to move", def = Direction.AIM)
|
||||
@Direction(includeDiagonals = true)
|
||||
BlockVector3 direction,
|
||||
@Arg(desc = "The pattern of blocks to leave", def = "air")
|
||||
Pattern replace,
|
||||
@Switch(name = 's', desc = "Shift the selection to the target location")
|
||||
boolean moveSelection,
|
||||
@Switch(name = 'a', desc = "Ignore air blocks")
|
||||
boolean ignoreAirBlocks,
|
||||
@Switch(name='b', desc = "TODO") boolean copyBiomes,
|
||||
|
||||
@Switch(name='e', desc = "TODO") boolean skipEntities,
|
||||
@Switch(name='a', desc = "TODO") boolean skipAir,
|
||||
InjectedValueAccess context) throws WorldEditException {
|
||||
@Arg(desc = "# of blocks to move", def = "1")
|
||||
int count,
|
||||
@Arg(desc = "The direction to move", def = Direction.AIM)
|
||||
@Direction(includeDiagonals = true)
|
||||
BlockVector3 direction,
|
||||
@Arg(desc = "The pattern of blocks to leave", def = "air")
|
||||
Pattern replace,
|
||||
@Switch(name = 's', desc = "Shift the selection to the target location")
|
||||
boolean moveSelection,
|
||||
@Switch(name = 'a', desc = "Ignore air blocks")
|
||||
boolean ignoreAirBlocks,
|
||||
@Switch(name='b', desc = "TODO")
|
||||
boolean copyBiomes,
|
||||
@Switch(name='e', desc = "TODO")
|
||||
boolean skipEntities,
|
||||
@Switch(name='a', desc = "TODO")
|
||||
boolean skipAir,
|
||||
InjectedValueAccess context) throws WorldEditException {
|
||||
checkCommandArgument(count >= 1, "Count must be >= 1");
|
||||
player.checkConfirmationRegion(() -> {
|
||||
int affected = editSession.moveRegion(region, direction, count, !skipAir, !skipEntities, copyBiomes, replace);
|
||||
|
||||
@ -526,18 +582,19 @@ public class RegionCommands extends MethodCommands {
|
||||
@CommandPermissions("worldedit.region.stack")
|
||||
@Logging(ORIENTATION_REGION)
|
||||
public void stack(FawePlayer player, EditSession editSession, LocalSession session,
|
||||
@Selection Region region,
|
||||
@Arg(desc = "# of copies to stack", def = "1")
|
||||
int count,
|
||||
@Arg(desc = "The direction to stack", def = Direction.AIM)
|
||||
@Direction(includeDiagonals = true)
|
||||
BlockVector3 direction,
|
||||
@Switch(name = 's', desc = "Shift the selection to the last stacked copy")
|
||||
boolean moveSelection,
|
||||
@Switch(name = 'b', desc = "//TODO") boolean copyBiomes,
|
||||
@Switch(name = 'e', desc = "//TODO") boolean skipEntities,
|
||||
@Switch(name = 'a', desc = "Ignore air blocks")
|
||||
boolean ignoreAirBlocks, @Switch(name='m', desc = "TODO") Mask sourceMask, InjectedValueAccess context) throws WorldEditException {
|
||||
@Selection Region region,
|
||||
@Arg(desc = "# of copies to stack", def = "1")
|
||||
int count,
|
||||
@Arg(desc = "The direction to stack", def = Direction.AIM)
|
||||
@Direction(includeDiagonals = true)
|
||||
BlockVector3 direction,
|
||||
@Switch(name = 's', desc = "Shift the selection to the last stacked copy")
|
||||
boolean moveSelection,
|
||||
@Switch(name = 'b', desc = "//TODO") boolean copyBiomes,
|
||||
@Switch(name = 'e', desc = "//TODO") boolean skipEntities,
|
||||
@Switch(name = 'a', desc = "Ignore air blocks")
|
||||
boolean ignoreAirBlocks,
|
||||
@Switch(name='m', desc = "TODO") Mask sourceMask, InjectedValueAccess context) throws WorldEditException {
|
||||
player.checkConfirmationStack(() -> {
|
||||
if (sourceMask != null) {
|
||||
editSession.addSourceMask(sourceMask);
|
||||
@ -562,24 +619,22 @@ public class RegionCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/deform",
|
||||
desc = "Deforms a selected region with an expression",
|
||||
descFooter =
|
||||
"Deforms a selected region with an expression\n" +
|
||||
"The expression is executed for each block and is expected\n" +
|
||||
"to modify the variables x, y and z to point to a new block\n" +
|
||||
"to fetch. See also tinyurl.com/wesyntax."
|
||||
)
|
||||
name = "/deform",
|
||||
desc = "Deforms a selected region with an expression",
|
||||
descFooter = "The expression is executed for each block and is expected\n" +
|
||||
"to modify the variables x, y and z to point to a new block\n" +
|
||||
"to fetch. See also https://tinyurl.com/weexpr"
|
||||
)
|
||||
@CommandPermissions("worldedit.region.deform")
|
||||
@Logging(ALL)
|
||||
public void deform(FawePlayer fp, Player player, LocalSession session, EditSession editSession, InjectedValueAccess context,
|
||||
@Selection Region region,
|
||||
@Arg(desc = "The expression to use", variable = true)
|
||||
List<String> expression,
|
||||
@Switch(name = 'r', desc = "Use the game's coordinate origin")
|
||||
boolean useRawCoords,
|
||||
@Switch(name = 'o', desc = "Use the selection's center as origin")
|
||||
boolean offset) throws WorldEditException {
|
||||
@Selection Region region,
|
||||
@Arg(desc = "The expression to use", variable = true)
|
||||
List<String> expression,
|
||||
@Switch(name = 'r', desc = "Use the game's coordinate origin")
|
||||
boolean useRawCoords,
|
||||
@Switch(name = 'o', desc = "Use the selection's center as origin")
|
||||
boolean offset) throws WorldEditException {
|
||||
final Vector3 zero;
|
||||
Vector3 unit;
|
||||
|
||||
@ -651,7 +706,7 @@ public class RegionCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/hollow",
|
||||
name = "/hollow",
|
||||
desc = "Hollows out the object contained in this selection",
|
||||
descFooter = "Hollows out the object contained in this selection.\n" +
|
||||
"Optionally fills the hollowed out part with the given block.\n" +
|
||||
@ -661,11 +716,11 @@ public class RegionCommands extends MethodCommands {
|
||||
@CommandPermissions("worldedit.region.hollow")
|
||||
@Logging(REGION)
|
||||
public void hollow(FawePlayer player, EditSession editSession,
|
||||
@Selection Region region,
|
||||
@Arg(desc = "Thickness of the shell to leave", def = "0")
|
||||
int thickness,
|
||||
@Arg(desc = "The pattern of blocks to replace the hollowed area with", def = "air")
|
||||
Pattern pattern,
|
||||
@Selection Region region,
|
||||
@Arg(desc = "Thickness of the shell to leave", def = "0")
|
||||
int thickness,
|
||||
@Arg(desc = "The pattern of blocks to replace the hollowed area with", def = "air")
|
||||
Pattern pattern,
|
||||
@Switch(name='m', desc = "Mask to hollow with") Mask mask,
|
||||
InjectedValueAccess context) throws WorldEditException {
|
||||
Mask finalMask = mask == null ? new SolidBlockMask(editSession) : mask;
|
||||
@ -682,10 +737,11 @@ public class RegionCommands extends MethodCommands {
|
||||
@CommandPermissions("worldedit.region.forest")
|
||||
@Logging(REGION)
|
||||
public void forest(Player player, EditSession editSession, @Selection Region region,
|
||||
@Arg(desc = "The type of tree to place", def = "tree")
|
||||
TreeType type,
|
||||
@Arg(desc = "The density of the forest", def = "5")
|
||||
double density) throws WorldEditException {
|
||||
@Arg(desc = "The type of tree to place", def = "tree")
|
||||
TreeType type,
|
||||
@Arg(desc = "The density of the forest", def = "5")
|
||||
double density) throws WorldEditException {
|
||||
checkCommandArgument(0 <= density && density <= 100, "Density must be in [0, 100]");
|
||||
int affected = editSession.makeForest(region, density / 100, type);
|
||||
BBC.COMMAND_TREE.send(player, affected);
|
||||
}
|
||||
@ -697,8 +753,9 @@ public class RegionCommands extends MethodCommands {
|
||||
@CommandPermissions("worldedit.region.flora")
|
||||
@Logging(REGION)
|
||||
public void flora(FawePlayer player, EditSession editSession, @Selection Region region,
|
||||
@Arg(desc = "The density of the forest", def = "5")
|
||||
double density, InjectedValueAccess context) throws WorldEditException {
|
||||
@Arg(desc = "The density of the forest", def = "5")
|
||||
double density, InjectedValueAccess context) throws WorldEditException {
|
||||
checkCommandArgument(0 <= density && density <= 100, "Density must be in [0, 100]");
|
||||
player.checkConfirmationRegion(() -> {
|
||||
FloraGenerator generator = new FloraGenerator(editSession);
|
||||
GroundFunction ground = new GroundFunction(new ExistingBlockMask(editSession), generator);
|
||||
|
@ -114,10 +114,11 @@ public class ScriptingCommands {
|
||||
file = new FileInputStream(f);
|
||||
}
|
||||
|
||||
DataInputStream in = new DataInputStream(file);
|
||||
byte[] data = new byte[in.available()];
|
||||
in.readFully(data);
|
||||
in.close();
|
||||
byte[] data;
|
||||
try (DataInputStream in = new DataInputStream(file)) {
|
||||
data = new byte[in.available()];
|
||||
in.readFully(data);
|
||||
}
|
||||
script = new String(data, 0, data.length, StandardCharsets.UTF_8);
|
||||
} catch (IOException e) {
|
||||
actor.printError("Script read error: " + e.getMessage());
|
||||
@ -131,11 +132,10 @@ public class ScriptingCommands {
|
||||
WorldEdit worldEdit = WorldEdit.getInstance();
|
||||
LocalSession session = worldEdit.getSessionManager().get(actor);
|
||||
|
||||
CraftScriptEngine engine = null;
|
||||
CraftScriptEngine engine;
|
||||
|
||||
Object result = null;
|
||||
try {
|
||||
|
||||
engine = new RhinoCraftScriptEngine();
|
||||
} catch (NoClassDefFoundError e) {
|
||||
actor.printError("Failed to find an installed script engine.");
|
||||
@ -182,10 +182,11 @@ public class ScriptingCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.scripting.execute")
|
||||
@Logging(ALL)
|
||||
public void execute(Player player, LocalSession session, InjectedValueAccess args) throws WorldEditException {
|
||||
final String[] scriptArgs = args.getSlice(1);
|
||||
final String filename = args.getString(0);
|
||||
|
||||
public void execute(Player player, LocalSession session,
|
||||
@Arg(desc = "Filename of the CraftScript to load")
|
||||
String filename,
|
||||
@Arg(desc = "Arguments to the CraftScript", def = "", variable = true)
|
||||
List<String> args) throws WorldEditException {
|
||||
if (!player.hasPermission("worldedit.scripting.execute." + filename)) {
|
||||
BBC.SCRIPTING_NO_PERM.send(player);
|
||||
return;
|
||||
@ -204,7 +205,8 @@ public class ScriptingCommands {
|
||||
player.printError("More info: https://github.com/boy0001/CraftScripts/");
|
||||
return;
|
||||
}
|
||||
runScript(LocationMaskedPlayerWrapper.unwrap(player), f, scriptArgs);
|
||||
worldEdit.runScript(LocationMaskedPlayerWrapper.unwrap(player), f, Stream.concat(Stream.of(filename), args.stream())
|
||||
.toArray(String[]::new));
|
||||
}
|
||||
|
||||
@Command(
|
||||
|
@ -27,7 +27,7 @@ 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;
|
||||
|
||||
import com.boydti.fawe.util.ExtentTraverser;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
@ -38,7 +38,6 @@ import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.command.util.Logging;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
@ -470,7 +469,7 @@ public class SelectionCommands {
|
||||
public void count(Player player, LocalSession session, EditSession editSession,
|
||||
@Arg(desc = "The mask of blocks to match")
|
||||
Mask mask) throws WorldEditException {
|
||||
int count = editSession.countBlock(session.getSelection(player.getWorld()), mask);
|
||||
int count = editSession.countBlocks(session.getSelection(player.getWorld()), mask);
|
||||
BBC.SELECTION_COUNT.send(player, count);
|
||||
}
|
||||
|
||||
|
@ -29,24 +29,29 @@ import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.util.formatting.component.PaginationBox;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
|
||||
import com.sk89q.worldedit.util.formatting.text.event.HoverEvent;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
import com.sk89q.worldedit.world.snapshot.InvalidSnapshotException;
|
||||
import com.sk89q.worldedit.world.snapshot.Snapshot;
|
||||
import com.sk89q.worldedit.world.storage.MissingWorldException;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Snapshot commands.
|
||||
*/
|
||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
@Command(aliases = {"snapshot", "snap"}, desc = "List, load and view information related to snapshots")
|
||||
public class SnapshotCommands {
|
||||
|
||||
private static final DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss z");
|
||||
@ -63,8 +68,8 @@ public class SnapshotCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.snapshots.list")
|
||||
public void list(Player player,
|
||||
@Arg(desc = "# of snapshots to list", def = "5")
|
||||
int num) throws WorldEditException {
|
||||
@ArgFlag(name = 'p', desc = "Page of results to return", def = "1")
|
||||
int page) throws WorldEditException {
|
||||
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
|
||||
@ -77,15 +82,7 @@ public class SnapshotCommands {
|
||||
List<Snapshot> snapshots = config.snapshotRepo.getSnapshots(true, player.getWorld().getName());
|
||||
|
||||
if (!snapshots.isEmpty()) {
|
||||
|
||||
num = Math.min(40, Math.max(5, num));
|
||||
|
||||
BBC.SNAPSHOT_LIST_HEADER.send(player, player.getWorld().getName());
|
||||
for (byte i = 0; i < Math.min(num, snapshots.size()); i++) {
|
||||
player.print((i + 1) + ". " + snapshots.get(i).getName());
|
||||
}
|
||||
|
||||
BBC.SNAPSHOT_LIST_FOOTER.send(player);
|
||||
player.print(new SnapshotListBox(player.getWorld().getName(), snapshots).create(page));
|
||||
} else {
|
||||
BBC.SNAPSHOT_NOT_AVAILABLE.send(player);
|
||||
|
||||
@ -200,19 +197,19 @@ public class SnapshotCommands {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Snapshot snapshot = config.snapshotRepo.getSnapshotBefore(date, player.getWorld().getName());
|
||||
try {
|
||||
Snapshot snapshot = config.snapshotRepo.getSnapshotBefore(date, player.getWorld().getName());
|
||||
|
||||
if (snapshot == null) {
|
||||
player.printError("Couldn't find a snapshot before "
|
||||
+ dateFormat.withZone(session.getTimeZone().toZoneId()).format(date) + ".");
|
||||
} else {
|
||||
session.setSnapshot(snapshot);
|
||||
BBC.SNAPSHOT_SET.send(player, snapshot.getName());
|
||||
}
|
||||
} catch (MissingWorldException ex) {
|
||||
BBC.SNAPSHOT_NOT_FOUND_WORLD.send(player);
|
||||
if (snapshot == null) {
|
||||
player.printError("Couldn't find a snapshot before "
|
||||
+ dateFormat.withZone(session.getTimeZone()).format(date) + ".");
|
||||
} else {
|
||||
session.setSnapshot(snapshot);
|
||||
BBC.SNAPSHOT_SET.send(player, snapshot.getName());
|
||||
}
|
||||
} catch (MissingWorldException ex) {
|
||||
BBC.SNAPSHOT_NOT_FOUND_WORLD.send(player);
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -231,18 +228,40 @@ public class SnapshotCommands {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Snapshot snapshot = config.snapshotRepo.getSnapshotAfter(date, player.getWorld().getName());
|
||||
if (snapshot == null) {
|
||||
player.printError("Couldn't find a snapshot after "
|
||||
+ dateFormat.withZone(session.getTimeZone().toZoneId()).format(date) + ".");
|
||||
} else {
|
||||
session.setSnapshot(snapshot);
|
||||
BBC.SNAPSHOT_SET.send(player, snapshot.getName());
|
||||
}
|
||||
} catch (MissingWorldException ex) {
|
||||
BBC.SNAPSHOT_NOT_FOUND_WORLD.send(player);
|
||||
try {
|
||||
Snapshot snapshot = config.snapshotRepo.getSnapshotAfter(date, player.getWorld().getName());
|
||||
if (snapshot == null) {
|
||||
player.printError("Couldn't find a snapshot after "
|
||||
+ dateFormat.withZone(session.getTimeZone()).format(date) + ".");
|
||||
} else {
|
||||
session.setSnapshot(snapshot);
|
||||
BBC.SNAPSHOT_SET.send(player, snapshot.getName());
|
||||
}
|
||||
} catch (MissingWorldException ex) {
|
||||
BBC.SNAPSHOT_NOT_FOUND_WORLD.send(player);
|
||||
}
|
||||
}
|
||||
|
||||
private static class SnapshotListBox extends PaginationBox {
|
||||
private final List<Snapshot> snapshots;
|
||||
|
||||
SnapshotListBox(String world, List<Snapshot> snapshots) {
|
||||
super("Snapshots for: " + world, "/snap list -p %page%");
|
||||
this.snapshots = snapshots;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getComponent(int number) {
|
||||
final Snapshot snapshot = snapshots.get(number);
|
||||
return TextComponent.of(number + 1 + ". ", TextColor.GOLD)
|
||||
.append(TextComponent.of(snapshot.getName(), TextColor.LIGHT_PURPLE)
|
||||
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to use")))
|
||||
.clickEvent(ClickEvent.of(ClickEvent.Action.RUN_COMMAND, "/snap use " + snapshot.getName())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComponentsSize() {
|
||||
return snapshots.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,9 +20,6 @@
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
@ -30,9 +27,14 @@ import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.command.tool.AreaPickaxe;
|
||||
import com.sk89q.worldedit.command.tool.RecursivePickaxe;
|
||||
import com.sk89q.worldedit.command.tool.SinglePickaxe;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
|
||||
@Command(aliases = {"superpickaxe", "pickaxe", "sp"}, desc = "Super-pickaxe commands: [More Info](https://goo.gl/aBtGHo)")
|
||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
public class SuperPickaxeCommands {
|
||||
private final WorldEdit we;
|
||||
|
||||
@ -41,9 +43,9 @@ public class SuperPickaxeCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "single",
|
||||
desc = "Enable the single block super pickaxe mode"
|
||||
)
|
||||
name = "single",
|
||||
desc = "Enable the single block super pickaxe mode"
|
||||
)
|
||||
@CommandPermissions("worldedit.superpickaxe")
|
||||
public void single(Player player, LocalSession session) throws WorldEditException {
|
||||
session.setSuperPickaxe(new SinglePickaxe());
|
||||
@ -52,14 +54,15 @@ public class SuperPickaxeCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "area",
|
||||
desc = "Enable the area super pickaxe pickaxe mode"
|
||||
)
|
||||
name = "area",
|
||||
desc = "Enable the area super pickaxe pickaxe mode"
|
||||
)
|
||||
@CommandPermissions("worldedit.superpickaxe.area")
|
||||
public void area(Player player, LocalSession session, InjectedValueAccess args) throws WorldEditException {
|
||||
public void area(Player player, LocalSession session,
|
||||
@Arg(desc = "The range of the area pickaxe")
|
||||
int range) throws WorldEditException {
|
||||
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
int range = args.getInteger(0);
|
||||
|
||||
if (range > config.maxSuperPickaxeSize) {
|
||||
BBC.TOOL_RANGE_ERROR.send(player, config.maxSuperPickaxeSize);
|
||||
@ -72,15 +75,16 @@ public class SuperPickaxeCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "recur",
|
||||
aliases = {"recursive"},
|
||||
desc = "Enable the recursive super pickaxe pickaxe mode"
|
||||
)
|
||||
name = "recursive",
|
||||
aliases = { "recur" },
|
||||
desc = "Enable the recursive super pickaxe pickaxe mode"
|
||||
)
|
||||
@CommandPermissions("worldedit.superpickaxe.recursive")
|
||||
public void recursive(Player player, LocalSession session, InjectedValueAccess args) throws WorldEditException {
|
||||
public void recursive(Player player, LocalSession session,
|
||||
@Arg(desc = "The range of the recursive pickaxe")
|
||||
double range) throws WorldEditException {
|
||||
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
double range = args.getDouble(0);
|
||||
|
||||
if (range > config.maxSuperPickaxeSize) {
|
||||
BBC.TOOL_RANGE_ERROR.send(player, config.maxSuperPickaxeSize);
|
||||
|
@ -10,39 +10,30 @@ import com.boydti.fawe.object.extent.ResettableExtent;
|
||||
import com.boydti.fawe.object.extent.ScaleTransform;
|
||||
import com.boydti.fawe.object.extent.TransformExtent;
|
||||
import com.boydti.fawe.util.ExtentTraverser;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extent.transform.BlockTransformExtent;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
import com.sk89q.worldedit.util.command.parametric.Optional;
|
||||
import java.util.Set;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
|
||||
@Command(aliases = {"transforms"},
|
||||
desc = "Help for the various transforms. [More Info](https://git.io/v9KHO)",
|
||||
descFooter = "Transforms modify how a block is placed\n" +
|
||||
" - Use [brackets] for arguments\n" +
|
||||
" - Use , to OR multiple\n" +
|
||||
" - Use & to AND multiple\n" +
|
||||
"More Info: https://git.io/v9KHO"
|
||||
)
|
||||
public class TransformCommands extends MethodCommands {
|
||||
public TransformCommands(WorldEdit worldEdit) {
|
||||
super(worldEdit);
|
||||
}
|
||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
public class TransformCommands {
|
||||
|
||||
@Command(
|
||||
name = "#linear",
|
||||
aliases = {"#l"},
|
||||
desc = "Sequentially pick from a list of transform"
|
||||
)
|
||||
)
|
||||
public ResettableExtent linear(Actor actor, LocalSession session, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
||||
if (other instanceof RandomTransform) {
|
||||
Set<ResettableExtent> extents = ((RandomTransform) other).getExtents();
|
||||
return new LinearTransform(extents.toArray(new ResettableExtent[extents.size()]));
|
||||
return new LinearTransform(extents.toArray(new ResettableExtent[0]));
|
||||
}
|
||||
return other;
|
||||
}
|
||||
@ -51,11 +42,11 @@ public class TransformCommands extends MethodCommands {
|
||||
name = "#linear3d",
|
||||
aliases = {"#l3d"},
|
||||
desc = "Use the x,y,z coordinate to pick a transform from the list"
|
||||
)
|
||||
)
|
||||
public ResettableExtent linear3d(Actor actor, LocalSession session, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
||||
if (other instanceof RandomTransform) {
|
||||
Set<ResettableExtent> extents = ((RandomTransform) other).getExtents();
|
||||
return new Linear3DTransform(extents.toArray(new ResettableExtent[extents.size()]));
|
||||
return new Linear3DTransform(extents.toArray(new ResettableExtent[0]));
|
||||
}
|
||||
return other;
|
||||
}
|
||||
@ -63,7 +54,7 @@ public class TransformCommands extends MethodCommands {
|
||||
@Command(
|
||||
name = "#pattern",
|
||||
desc = "Always use a specific pattern"
|
||||
)
|
||||
)
|
||||
public ResettableExtent pattern(Actor actor, LocalSession session, Pattern pattern, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
||||
return new PatternTransform(other, pattern);
|
||||
}
|
||||
@ -71,7 +62,7 @@ public class TransformCommands extends MethodCommands {
|
||||
@Command(
|
||||
name = "#offset",
|
||||
desc = "Offset transform"
|
||||
)
|
||||
)
|
||||
public ResettableExtent offset(Actor actor, LocalSession session, double x, double y, double z, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
||||
return new OffsetExtent(other, (int) x, (int) y, (int) z);
|
||||
}
|
||||
@ -88,7 +79,7 @@ public class TransformCommands extends MethodCommands {
|
||||
@Command(
|
||||
name = "#scale",
|
||||
desc = "All changes will be scaled"
|
||||
)
|
||||
)
|
||||
public ResettableExtent scale(Actor actor, LocalSession session, double x, double y, double z, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
||||
return new ScaleTransform(other, x, y, z);
|
||||
}
|
||||
@ -96,10 +87,10 @@ public class TransformCommands extends MethodCommands {
|
||||
@Command(
|
||||
name = "#rotate",
|
||||
desc = "All changes will be rotate around the initial position"
|
||||
)
|
||||
)
|
||||
public ResettableExtent rotate(Player player, LocalSession session, double x, double y, double z, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
||||
ExtentTraverser traverser = new ExtentTraverser(other).find(TransformExtent.class);
|
||||
BlockTransformExtent affine = (TransformExtent) (traverser != null ? traverser.get() : null);
|
||||
ExtentTraverser<TransformExtent> traverser = new ExtentTraverser(other).find(TransformExtent.class);
|
||||
BlockTransformExtent affine = traverser != null ? traverser.get() : null;
|
||||
if (affine == null) {
|
||||
other = affine = new TransformExtent(other);
|
||||
}
|
||||
@ -108,6 +99,6 @@ public class TransformCommands extends MethodCommands {
|
||||
transform = transform.rotateY(y);
|
||||
transform = transform.rotateZ(z);
|
||||
affine.setTransform(transform);
|
||||
return (ResettableExtent) other;
|
||||
return other;
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ package com.sk89q.worldedit.command;
|
||||
import static com.sk89q.worldedit.command.util.Logging.LogMode.PLACEMENT;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.object.DelegateConsumer;
|
||||
@ -32,7 +31,6 @@ import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.boydti.fawe.util.chat.Message;
|
||||
import com.boydti.fawe.util.image.ImageUtil;
|
||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
@ -63,16 +61,13 @@ import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.visitor.EntityVisitor;
|
||||
|
||||
import com.sk89q.worldedit.internal.annotation.Range;
|
||||
import com.sk89q.worldedit.internal.expression.Expression;
|
||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.CylinderRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.command.CommandMapping;
|
||||
import com.sk89q.worldedit.util.command.Dispatcher;
|
||||
import com.sk89q.worldedit.internal.annotation.Range;
|
||||
import com.sk89q.worldedit.util.formatting.component.SubtleFormat;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
@ -99,12 +94,12 @@ 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;
|
||||
|
||||
/**
|
||||
* Utility commands.
|
||||
*/
|
||||
@CommandContainer(superTypes = {CommandPermissionsConditionGenerator.Registration.class, CommandQueuedConditionGenerator.Registration.class})
|
||||
//@Command(aliases = {}, desc = "Various utility commands: [More Info](http://wiki.sk89q.com/wiki/WorldEdit/Utilities)")
|
||||
public class UtilityCommands {
|
||||
|
||||
private final WorldEdit we;
|
||||
@ -774,7 +769,7 @@ public class UtilityCommands {
|
||||
return page;
|
||||
}
|
||||
|
||||
public static int getFiles(File dir, Actor actor, InjectedValueAccess args, @Range(min = 0) int page, int perPage, String formatName, boolean playerFolder, Consumer<File> forEachFile) {
|
||||
public static int getFiles(File dir, Actor actor, InjectedValueAccess args, @org.jetbrains.annotations.Range(from = 0, to = ) int page, int perPage, String formatName, boolean playerFolder, Consumer<File> forEachFile) {
|
||||
Consumer<File> rootFunction = forEachFile;
|
||||
//schem list all <path>
|
||||
|
||||
|
Reference in New Issue
Block a user