Search in sources :

Example 11 with Command

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());
}
Also used : Location(com.sk89q.worldedit.util.Location) Locatable(com.sk89q.worldedit.extension.platform.Locatable) Logging(com.sk89q.worldedit.command.util.Logging) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 12 with Command

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");
}
Also used : FloodFillTool(com.sk89q.worldedit.command.tool.FloodFillTool) LocalConfiguration(com.sk89q.worldedit.LocalConfiguration) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 13 with Command

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;
}
Also used : BlockVector3(com.sk89q.worldedit.math.BlockVector3) Logging(com.sk89q.worldedit.command.util.Logging) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 14 with Command

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;
}
Also used : CuboidRegion(com.sk89q.worldedit.regions.CuboidRegion) CylinderRegion(com.sk89q.worldedit.regions.CylinderRegion) Region(com.sk89q.worldedit.regions.Region) MaskTraverser(com.fastasyncworldedit.core.util.MaskTraverser) CuboidRegion(com.sk89q.worldedit.regions.CuboidRegion) ExistingBlockMask(com.sk89q.worldedit.function.mask.ExistingBlockMask) BlockVector3(com.sk89q.worldedit.math.BlockVector3) Logging(com.sk89q.worldedit.command.util.Logging) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 15 with Command

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;
}
Also used : ConvexPolyhedralRegion(com.sk89q.worldedit.regions.ConvexPolyhedralRegion) ArrayList(java.util.ArrayList) BlockVector3(com.sk89q.worldedit.math.BlockVector3) Logging(com.sk89q.worldedit.command.util.Logging) Command(org.enginehub.piston.annotation.Command) Confirm(com.sk89q.worldedit.command.util.annotation.Confirm) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Aggregations

Command (org.enginehub.piston.annotation.Command)137 CommandPermissions (com.sk89q.worldedit.command.util.CommandPermissions)134 Logging (com.sk89q.worldedit.command.util.Logging)47 BlockVector3 (com.sk89q.worldedit.math.BlockVector3)34 ScatterCommand (com.fastasyncworldedit.core.command.tool.brush.ScatterCommand)25 Confirm (com.sk89q.worldedit.command.util.annotation.Confirm)22 LocalConfiguration (com.sk89q.worldedit.LocalConfiguration)21 Region (com.sk89q.worldedit.regions.Region)19 File (java.io.File)18 Preload (com.sk89q.worldedit.command.util.annotation.Preload)17 ClipboardHolder (com.sk89q.worldedit.session.ClipboardHolder)16 URIClipboardHolder (com.fastasyncworldedit.core.extent.clipboard.URIClipboardHolder)15 MultiClipboardHolder (com.fastasyncworldedit.core.extent.clipboard.MultiClipboardHolder)14 MaskTraverser (com.fastasyncworldedit.core.util.MaskTraverser)13 Mask (com.sk89q.worldedit.function.mask.Mask)12 BrushTool (com.sk89q.worldedit.command.tool.BrushTool)11 Player (com.sk89q.worldedit.entity.Player)11 Component (com.sk89q.worldedit.util.formatting.text.Component)11 TextComponent (com.sk89q.worldedit.util.formatting.text.TextComponent)11 IOException (java.io.IOException)11