use of org.enginehub.piston.annotation.Command in project FastAsyncWorldEdit by IntellectualSites.
the class SelectionCommands method pos1.
@Command(name = "/pos1", aliases = "/1", desc = "Set position 1")
@Logging(POSITION)
@CommandPermissions("worldedit.selection.pos")
public void pos1(Actor actor, World world, LocalSession session, @Arg(desc = "Coordinates to set position 1 to", def = "") BlockVector3 coordinates) throws WorldEditException {
Location pos;
// FAWE start - clamp
if (coordinates != null) {
pos = new Location(world, coordinates.toVector3().clampY(world.getMinY(), world.getMaxY()));
} else if (actor instanceof Locatable) {
pos = ((Locatable) actor).getBlockLocation().clampY(world.getMinY(), world.getMaxY());
// FAWE end
} else {
actor.print(Caption.of("worldedit.pos.console-require-coords"));
return;
}
if (!session.getRegionSelector(world).selectPrimary(pos.toVector().toBlockPoint(), ActorSelectorLimits.forActor(actor))) {
actor.print(Caption.of("worldedit.pos.already-set"));
return;
}
session.getRegionSelector(world).explainPrimarySelection(actor, session, pos.toVector().toBlockPoint());
}
use of org.enginehub.piston.annotation.Command in project FastAsyncWorldEdit by IntellectualSites.
the class ToolCommands method floodFill.
@Command(name = "floodfill", aliases = { "flood", "/flood", "/floodfill" }, desc = "Flood fill tool")
@CommandPermissions("worldedit.tool.flood-fill")
public void floodFill(Player player, LocalSession session, @Arg(desc = "The pattern to flood fill") Pattern pattern, @Arg(desc = "The range to perform the fill") int range) throws WorldEditException {
LocalConfiguration config = we.getConfiguration();
if (range > config.maxSuperPickaxeSize) {
player.print(Caption.of("worldedit.tool.superpickaxe.max-range", TextComponent.of(config.maxSuperPickaxeSize)));
return;
}
setTool(player, session, new FloodFillTool(range, pattern), "worldedit.tool.floodfill.equip");
}
use of org.enginehub.piston.annotation.Command in project FastAsyncWorldEdit by IntellectualSites.
the class UtilityCommands method fillr.
/*
@Command(
name = "masks",
desc = "View help about masks",
descFooter = "Masks determine if a block can be placed\n" +
" - Use [brackets] for arguments\n" +
" - Use , to OR multiple\n" +
" - Use & to AND multiple\n" +
"e.g., >[stone,dirt],#light[0][5],$jungle\n" +
"More Info: https://git.io/v9r4K"
)
@CommandQueued(false)
@CommandPermissions("worldedit.masks")
public void masks(Player player, LocalSession session, InjectedValueAccess args) throws WorldEditException {
displayModifierHelp(player, DefaultMaskParser.class, args);
}
@Command(
name = "transforms",
desc = "View help about transforms",
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",
)
@CommandQueued(false)
@CommandPermissions("worldedit.transforms")
public void transforms(Player player, LocalSession session, InjectedValueAccess args) throws WorldEditException {
displayModifierHelp(player, DefaultTransformParser.class, args);
}
private void displayModifierHelp(Player player, Class<? extends FaweParser> clazz, InjectedValueAccess args) {
FaweParser parser = FaweAPI.getParser(clazz);
if (args.argsLength() == 0) {
String base = getCommand().aliases()[0];
UsageMessage msg = new UsageMessage(getCallable(), "/" + base, args.getLocals());
msg.newline().paginate(base, 0, 1).send(player);
return;
}
if (parser != null) {
CommandMapping mapping = parser.getDispatcher().get(args.getString(0));
if (mapping != null) {
new UsageMessage(mapping.getCallable(), args.getString(0), args.getLocals()) {
@Override
public String separateArg(String arg) {
return "&7[" + arg + "&7]";
}
}.send(player);
} else {
UtilityCommands.help(args, player, getCommand().aliases()[0] + " ", parser.getDispatcher());
}
}
}
*/
@Command(name = "/fillr", desc = "Fill a hole recursively")
@CommandPermissions("worldedit.fill.recursive")
@Logging(PLACEMENT)
public int fillr(Actor actor, LocalSession session, EditSession editSession, @Arg(desc = "The blocks to fill with") Pattern pattern, // FAWE start - we take an expression over a double
@Arg(desc = "The radius to fill in") Expression radiusExp, // FAWE end
@Arg(desc = "The depth to fill", def = "") Integer depth) throws WorldEditException {
// FAWE start
double radius = radiusExp.evaluate();
// FAWE end
radius = Math.max(1, radius);
we.checkMaxRadius(radius);
depth = depth == null ? Integer.MAX_VALUE : Math.max(1, depth);
we.checkMaxRadius(radius);
BlockVector3 pos = session.getPlacementPosition(actor);
int affected = editSession.fillXZ(pos, pattern, radius, depth, true);
actor.print(Caption.of("worldedit.fillr.created", TextComponent.of(affected)));
return affected;
}
use of org.enginehub.piston.annotation.Command in project FastAsyncWorldEdit by IntellectualSites.
the class UtilityCommands method replaceNear.
@Command(name = "replacenear", aliases = { "/replacenear" }, desc = "Replace nearby blocks")
@CommandPermissions("worldedit.replacenear")
@Logging(PLACEMENT)
public int replaceNear(Actor actor, World world, LocalSession session, EditSession editSession, @Arg(desc = "The radius of the square to remove in") int radius, @Arg(desc = "The mask matching blocks to remove", def = "") Mask from, @Arg(desc = "The pattern of blocks to replace with") Pattern to) throws WorldEditException {
// FAWE start > the mask will have been initialised with a WorldWrapper extent (very bad/slow)
new MaskTraverser(from).setNewExtent(editSession);
// FAWE end
radius = Math.max(1, radius);
we.checkMaxRadius(radius);
BlockVector3 base = session.getPlacementPosition(actor);
BlockVector3 min = base.subtract(radius, radius, radius);
BlockVector3 max = base.add(radius, radius, radius);
Region region = new CuboidRegion(world, min, max);
if (from == null) {
from = new ExistingBlockMask(editSession);
}
int affected = editSession.replaceBlocks(region, from, to);
actor.print(Caption.of("worldedit.replacenear.replaced", TextComponent.of(affected)));
return affected;
}
use of org.enginehub.piston.annotation.Command in project FastAsyncWorldEdit by IntellectualSites.
the class RegionCommands method curve.
@Command(name = "/curve", desc = "Draws a spline through selected points", descFooter = "Can only be used with a convex polyhedral selection")
@CommandPermissions("worldedit.region.curve")
@Logging(REGION)
@Confirm(Confirm.Processor.REGION)
public int curve(Actor actor, EditSession editSession, @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) throws WorldEditException {
if (!(region instanceof ConvexPolyhedralRegion)) {
actor.print(Caption.of("worldedit.curve.invalid-type"));
return 0;
}
checkCommandArgument(thickness >= 0, "Thickness must be >= 0");
ConvexPolyhedralRegion cpregion = (ConvexPolyhedralRegion) region;
List<BlockVector3> vectors = new ArrayList<>(cpregion.getVertices());
int blocksChanged = editSession.drawSpline(pattern, vectors, 0, 0, 0, 10, thickness, !shell);
actor.print(Caption.of("worldedit.curve.changed", TextComponent.of(blocksChanged)));
return blocksChanged;
}
Aggregations