Search in sources :

Example 76 with CommandPermissions

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

the class SelectionCommands method shift.

@Command(name = "/shift", desc = "Shift the selection area")
@Logging(REGION)
@CommandPermissions("worldedit.selection.shift")
public void shift(Actor actor, World world, LocalSession session, @Arg(desc = "Amount to shift the selection by") int amount, @Arg(desc = "Direction to contract", def = Direction.AIM) @MultiDirection List<BlockVector3> direction) throws WorldEditException {
    try {
        Region region = session.getSelection(world);
        for (BlockVector3 dir : direction) {
            region.shift(dir.multiply(amount));
        }
        session.getRegionSelector(world).learnChanges();
        session.getRegionSelector(world).explainRegionAdjust(actor, session);
        actor.print(Caption.of("worldedit.shift.shifted"));
    } catch (RegionOperationException e) {
        actor.printError(TextComponent.of(e.getMessage()));
    }
}
Also used : RegionOperationException(com.sk89q.worldedit.regions.RegionOperationException) Region(com.sk89q.worldedit.regions.Region) 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 77 with CommandPermissions

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

the class SelectionCommands method inset.

@Command(name = "/inset", desc = "Inset the selection area")
@Logging(REGION)
@CommandPermissions("worldedit.selection.inset")
public void inset(Actor actor, World world, LocalSession session, @Arg(desc = "Amount to contract the selection by in all directions") int amount, @Switch(name = 'h', desc = "Only contract horizontally") boolean onlyHorizontal, @Switch(name = 'v', desc = "Only contract vertically") boolean onlyVertical) throws WorldEditException {
    Region region = session.getSelection(world);
    region.contract(getChangesForEachDir(amount, onlyHorizontal, onlyVertical));
    session.getRegionSelector(world).learnChanges();
    session.getRegionSelector(world).explainRegionAdjust(actor, session);
    actor.print(Caption.of("worldedit.inset.inset"));
}
Also used : Region(com.sk89q.worldedit.regions.Region) Logging(com.sk89q.worldedit.command.util.Logging) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 78 with CommandPermissions

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

the class SnapshotCommands method sel.

@Command(name = "sel", desc = "Choose the snapshot based on the list id")
@CommandPermissions("worldedit.snapshots.restore")
void sel(Actor actor, World world, LocalSession session, @Arg(desc = "The list ID to select") int index) throws IOException {
    LocalConfiguration config = we.getConfiguration();
    checkSnapshotsConfigured(config);
    if (config.snapshotRepo != null) {
        legacy.sel(actor, world, session, index);
        return;
    }
    if (index < 1) {
        actor.print(Caption.of("worldedit.snapshot.index-above-0"));
        return;
    }
    List<Snapshot> snapshots;
    try (Stream<Snapshot> snapshotStream = config.snapshotDatabase.getSnapshotsNewestFirst(world.getName())) {
        snapshots = snapshotStream.collect(toList());
    }
    if (snapshots.size() < index) {
        actor.print(Caption.of("worldedit.snapshot.index-oob", TextComponent.of(snapshots.size())));
        return;
    }
    Snapshot snapshot = snapshots.get(index - 1);
    if (snapshot == null) {
        actor.print(Caption.of("worldedit.restore.not-available"));
        return;
    }
    if (session.getSnapshotExperimental() != null) {
        session.getSnapshotExperimental().close();
    }
    session.setSnapshotExperimental(snapshot);
    actor.print(Caption.of("worldedit.snapshot.use", TextComponent.of(snapshot.getInfo().getDisplayName())));
}
Also used : Snapshot(com.sk89q.worldedit.world.snapshot.experimental.Snapshot) LocalConfiguration(com.sk89q.worldedit.LocalConfiguration) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 79 with CommandPermissions

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

the class SnapshotUtilCommands method restore.

@Command(name = "restore", aliases = { "/restore" }, desc = "Restore the selection from a snapshot")
@Logging(REGION)
@CommandPermissions("worldedit.snapshots.restore")
public void restore(Actor actor, World world, LocalSession session, EditSession editSession, @Arg(name = "snapshot", desc = "The snapshot to restore", def = "") String snapshotName, // FAWE start - biome and entity restore
@Switch(name = 'b', desc = "If biomes should be restored. If restoring from pre-1.15 to 1.15+, biomes may not be " + "exactly the same due to 3D biomes.") boolean restoreBiomes, @Switch(name = 'e', desc = "If entities should be restored. Will cause issues with duplicate entities if all " + "original entities were not removed.") boolean restoreEntities) throws // FAWE end
WorldEditException, IOException {
    LocalConfiguration config = we.getConfiguration();
    checkSnapshotsConfigured(config);
    if (config.snapshotRepo != null) {
        // FAWE start - biome and entity restore
        legacy.restore(actor, world, session, editSession, snapshotName, restoreBiomes, restoreEntities);
        // FAWE end
        return;
    }
    Region region = session.getSelection(world);
    Snapshot snapshot;
    if (snapshotName != null) {
        URI uri = resolveSnapshotName(config, snapshotName);
        Optional<Snapshot> snapOpt = config.snapshotDatabase.getSnapshot(uri);
        if (!snapOpt.isPresent()) {
            actor.print(Caption.of("worldedit.restore.not-available"));
            return;
        }
        snapshot = snapOpt.get();
    } else {
        snapshot = session.getSnapshotExperimental();
    }
    // No snapshot set?
    if (snapshot == null) {
        try (Stream<Snapshot> snapshotStream = config.snapshotDatabase.getSnapshotsNewestFirst(world.getName())) {
            snapshot = snapshotStream.findFirst().orElse(null);
        }
        if (snapshot == null) {
            actor.print(Caption.of("worldedit.restore.none-for-specific-world", TextComponent.of(world.getName())));
            return;
        }
    }
    actor.print(Caption.of("worldedit.restore.loaded", TextComponent.of(snapshot.getInfo().getDisplayName())));
    try {
        // Restore snapshot
        // FAWE start - biome and entity restore
        SnapshotRestore restore = new SnapshotRestore(snapshot, editSession, region, restoreBiomes, restoreEntities);
        // FAWE end
        restore.restore();
        if (restore.hadTotalFailure()) {
            String error = restore.getLastErrorMessage();
            if (!restore.getMissingChunks().isEmpty()) {
                actor.print(Caption.of("worldedit.restore.chunk-not-present"));
            } else if (error != null) {
                actor.print(Caption.of("worldedit.restore.block-place-failed"));
                actor.print(Caption.of("worldedit.restore.block-place-error", TextComponent.of(error)));
            } else {
                actor.print(Caption.of("worldedit.restore.chunk-load-failed"));
            }
        } else {
            actor.print(Caption.of("worldedit.restore.restored", TextComponent.of(restore.getMissingChunks().size()), TextComponent.of(restore.getErrorChunks().size())));
        }
    } finally {
        try {
            snapshot.close();
        } catch (IOException ignored) {
        }
    }
}
Also used : Snapshot(com.sk89q.worldedit.world.snapshot.experimental.Snapshot) SnapshotRestore(com.sk89q.worldedit.world.snapshot.experimental.SnapshotRestore) Region(com.sk89q.worldedit.regions.Region) IOException(java.io.IOException) LocalConfiguration(com.sk89q.worldedit.LocalConfiguration) URI(java.net.URI) Logging(com.sk89q.worldedit.command.util.Logging) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 80 with CommandPermissions

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

the class SuperPickaxeCommands method area.

@Command(name = "area", desc = "Enable the area super pickaxe pickaxe mode")
@CommandPermissions("worldedit.superpickaxe.area")
public void area(Player player, LocalSession session, @Arg(desc = "The range of the area pickaxe") 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;
    }
    session.setSuperPickaxe(new AreaPickaxe(range));
    session.enableSuperPickAxe();
    player.print(Caption.of("worldedit.tool.superpickaxe.mode.area"));
}
Also used : AreaPickaxe(com.sk89q.worldedit.command.tool.AreaPickaxe) LocalConfiguration(com.sk89q.worldedit.LocalConfiguration) 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