Search in sources :

Example 56 with CommandPermissions

use of com.sk89q.worldedit.command.util.CommandPermissions in project FastAsyncWorldEdit by IntellectualSites.

the class ToolUtilCommands method smask.

@Command(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, @Arg(desc = "The destination mask", def = "") Mask maskArg, @Switch(name = 'h', desc = "Whether the offhand should be considered or not") boolean offHand, Arguments arguments) throws WorldEditException {
    BrushTool tool = session.getBrushTool(player, false);
    if (tool == null) {
        player.print(Caption.of("fawe.worldedit.brush.brush.none"));
        return;
    }
    if (maskArg == null) {
        player.print(Caption.of("fawe.worldedit.brush.brush.source.mask.disabled"));
        tool.setSourceMask(null);
        return;
    }
    BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
    String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring();
    settings.addSetting(BrushSettings.SettingType.SOURCE_MASK, lastArg);
    settings.setSourceMask(maskArg);
    tool.update();
    player.print(Caption.of("fawe.worldedit.brush.brush.source.mask"));
}
Also used : BrushTool(com.sk89q.worldedit.command.tool.BrushTool) BrushSettings(com.fastasyncworldedit.core.command.tool.brush.BrushSettings) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 57 with CommandPermissions

use of com.sk89q.worldedit.command.util.CommandPermissions in project FastAsyncWorldEdit by IntellectualSites.

the class ToolUtilCommands method secondary.

@Command(name = "secondary", aliases = { "/secondary" }, desc = "Set the left click brush", descFooter = "Set the left click brush")
@CommandPermissions("worldedit.brush.secondary")
public void secondary(Player player, LocalSession session, @Arg(desc = "The brush command", variable = true) List<String> commandStr) throws WorldEditException {
    BaseItem item = player.getItemInHand(HandSide.MAIN_HAND);
    BrushTool tool = session.getBrushTool(player, false);
    session.setTool(item, null, player);
    String cmd = "brush " + StringMan.join(commandStr, " ");
    CommandEvent event = new CommandEvent(player, cmd);
    PlatformCommandManager.getInstance().handleCommandOnCurrentThread(event);
    BrushTool newTool = session.getBrushTool(item, player, false);
    if (newTool != null && tool != null) {
        newTool.setPrimary(tool.getPrimary());
    }
}
Also used : BrushTool(com.sk89q.worldedit.command.tool.BrushTool) CommandEvent(com.sk89q.worldedit.event.platform.CommandEvent) BaseItem(com.sk89q.worldedit.blocks.BaseItem) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 58 with CommandPermissions

use of com.sk89q.worldedit.command.util.CommandPermissions 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 59 with CommandPermissions

use of com.sk89q.worldedit.command.util.CommandPermissions 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 60 with CommandPermissions

use of com.sk89q.worldedit.command.util.CommandPermissions in project FastAsyncWorldEdit by IntellectualSites.

the class WorldEditCommands method reload.

@Command(name = "reload", desc = "Reload configuration and translations")
@CommandPermissions("worldedit.reload")
public void reload(Actor actor) {
    we.getPlatformManager().queryCapability(Capability.CONFIGURATION).reload();
    we.getEventBus().post(new ConfigurationLoadEvent(we.getPlatformManager().queryCapability(Capability.CONFIGURATION).getConfiguration()));
    // FAWE start
    Fawe.instance().setupConfigs();
    // FAWE end
    actor.print(Caption.of("worldedit.reload.config"));
}
Also used : ConfigurationLoadEvent(com.sk89q.worldedit.event.platform.ConfigurationLoadEvent) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Aggregations

CommandPermissions (com.sk89q.worldedit.command.util.CommandPermissions)133 Command (org.enginehub.piston.annotation.Command)133 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)20 Region (com.sk89q.worldedit.regions.Region)19 Preload (com.sk89q.worldedit.command.util.annotation.Preload)17 File (java.io.File)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)11 IOException (java.io.IOException)11 BrushTool (com.sk89q.worldedit.command.tool.BrushTool)10 Player (com.sk89q.worldedit.entity.Player)10 Clipboard (com.sk89q.worldedit.extent.clipboard.Clipboard)10 Location (com.sk89q.worldedit.util.Location)10