Search in sources :

Example 51 with CommandPermissions

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

the class SnapshotCommands method use.

@Command(name = "use", desc = "Choose a snapshot to use")
@CommandPermissions("worldedit.snapshots.restore")
void use(Actor actor, World world, LocalSession session, @Arg(desc = "Snapshot to use") String name) throws IOException {
    LocalConfiguration config = we.getConfiguration();
    checkSnapshotsConfigured(config);
    if (config.snapshotRepo != null) {
        legacy.use(actor, world, session, name);
        return;
    }
    // Want the latest snapshot?
    if (name.equalsIgnoreCase("latest")) {
        Snapshot snapshot;
        try (Stream<Snapshot> snapshotStream = config.snapshotDatabase.getSnapshotsNewestFirst(world.getName())) {
            snapshot = snapshotStream.findFirst().orElse(null);
        }
        if (snapshot != null) {
            if (session.getSnapshotExperimental() != null) {
                session.getSnapshotExperimental().close();
            }
            session.setSnapshot(null);
            actor.print(Caption.of("worldedit.snapshot.use.newest"));
        } else {
            actor.print(Caption.of("worldedit.restore.none-for-world"));
        }
    } else {
        URI uri = resolveSnapshotName(config, name);
        Optional<Snapshot> snapshot = config.snapshotDatabase.getSnapshot(uri);
        if (snapshot.isPresent()) {
            if (session.getSnapshotExperimental() != null) {
                session.getSnapshotExperimental().close();
            }
            session.setSnapshotExperimental(snapshot.get());
            actor.print(Caption.of("worldedit.snapshot.use", TextComponent.of(name)));
        } else {
            actor.print(Caption.of("worldedit.restore.not-available"));
        }
    }
}
Also used : Snapshot(com.sk89q.worldedit.world.snapshot.experimental.Snapshot) LocalConfiguration(com.sk89q.worldedit.LocalConfiguration) URI(java.net.URI) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 52 with CommandPermissions

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

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

the class ToolUtilCommands method targetOffset.

@Command(name = "targetoffset", aliases = { "to" }, desc = "Set the targeting mask")
@CommandPermissions("worldedit.brush.targetoffset")
public void targetOffset(Player player, EditSession editSession, LocalSession session, @Arg(name = "offset", desc = "offset", def = "0") int offset) throws WorldEditException {
    BrushTool tool = session.getBrushTool(player, false);
    if (tool == null) {
        player.print(Caption.of("fawe.worldedit.brush.brush.none"));
        return;
    }
    tool.setTargetOffset(offset);
    player.print(Caption.of("fawe.worldedit.brush.brush.target.offset.set", offset));
}
Also used : BrushTool(com.sk89q.worldedit.command.tool.BrushTool) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 54 with CommandPermissions

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

the class ToolUtilCommands method material.

// FAWE end
@Command(name = "material", aliases = { "mat", "/material", "pattern" }, desc = "Set the brush material")
@CommandPermissions("worldedit.brush.options.material")
public void material(Player player, LocalSession session, @Arg(desc = "The pattern of blocks to use") Pattern pattern, // FAWE start - add offhand
@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 (pattern == null) {
        tool.setFill(null);
    } else {
        BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
        settings.setFill(pattern);
        String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring();
        settings.addSetting(BrushSettings.SettingType.FILL, lastArg);
        tool.update();
    }
    // FAWE end
    player.print(Caption.of("worldedit.tool.material.set"));
}
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 55 with CommandPermissions

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

the class ToolUtilCommands method scroll.

@Command(name = "scroll", desc = "Toggle between different target modes")
@CommandPermissions("worldedit.brush.scroll")
public void scroll(Player player, EditSession editSession, LocalSession session, @Switch(name = 'h', desc = "Whether the offhand should be considered or not") boolean offHand, @Arg(desc = "Target Modes", def = "none") Scroll.Action mode, @Arg(desc = "The scroll action", variable = true) List<String> commandStr) throws WorldEditException {
    BrushTool bt = session.getBrushTool(player, false);
    if (bt == null) {
        player.print(Caption.of("fawe.worldedit.brush.brush.none"));
        return;
    }
    BrushSettings settings = offHand ? bt.getOffHand() : bt.getContext();
    Scroll action = Scroll.fromArguments(bt, player, session, mode, commandStr, true);
    settings.setScrollAction(action);
    if (mode == Scroll.Action.NONE) {
        player.print(Caption.of("fawe.worldedit.brush.brush.scroll.action.unset"));
    } else if (action != null) {
        String full = (mode.name().toLowerCase(Locale.ROOT) + " " + StringMan.join(commandStr, " ")).trim();
        settings.addSetting(BrushSettings.SettingType.SCROLL_ACTION, full);
        player.print(Caption.of("fawe.worldedit.brush.brush.scroll.action.set", mode));
    }
    bt.update();
}
Also used : BrushTool(com.sk89q.worldedit.command.tool.BrushTool) Scroll(com.fastasyncworldedit.core.command.tool.scroll.Scroll) BrushSettings(com.fastasyncworldedit.core.command.tool.brush.BrushSettings) 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