Search in sources :

Example 46 with CommandPermissions

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

the class PaintBrushCommands method item.

@Command(name = "item", desc = "Use an item")
@CommandPermissions("worldedit.brush.item")
public void item(CommandParameters parameters, Player player, LocalSession localSession, @Arg(desc = "The type of item to use") BaseItem item, @Arg(desc = "The direction in which the item will be applied", def = "up") @Direction(includeDiagonals = true) com.sk89q.worldedit.util.Direction direction) throws WorldEditException {
    player.print(TextComponent.builder().append("WARNING: ").append(Caption.of("worldedit.brush.paint.item.warning")).build());
    setPaintBrush(parameters, player, localSession, new ItemUseFactory(item, direction));
}
Also used : ItemUseFactory(com.sk89q.worldedit.command.factory.ItemUseFactory) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 47 with CommandPermissions

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

the class RegionCommands method nbtinfo.

@Command(name = "/nbtinfo", aliases = "/nbt", desc = "View nbt info for a block")
@CommandPermissions("worldedit.nbtinfo")
public void nbtinfo(Player player, EditSession editSession) {
    Location pos = player.getBlockTrace(128);
    if (pos == null) {
        player.print(Caption.of("fawe.navigation.no.block"));
        return;
    }
    CompoundTag nbt = editSession.getFullBlock(pos.toBlockPoint()).getNbtData();
    if (nbt != null) {
        player.print(TextComponent.of(nbt.getValue().toString()));
    } else {
        player.print(Caption.of("fawe.navigation.no.block"));
    }
}
Also used : CompoundTag(com.sk89q.jnbt.CompoundTag) Location(com.sk89q.worldedit.util.Location) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 48 with CommandPermissions

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

the class SnapshotCommands method after.

@Command(name = "after", desc = "Choose the nearest snapshot after a date")
@CommandPermissions("worldedit.snapshots.restore")
void after(Actor actor, World world, LocalSession session, @Arg(desc = "The soonest date that may be used") ZonedDateTime date) throws IOException {
    LocalConfiguration config = we.getConfiguration();
    checkSnapshotsConfigured(config);
    if (config.snapshotRepo != null) {
        legacy.after(actor, world, session, date);
        return;
    }
    Snapshot snapshot;
    try (Stream<Snapshot> snapshotStream = config.snapshotDatabase.getSnapshotsNewestFirst(world.getName())) {
        snapshot = snapshotStream.findFirst().orElse(null);
    }
    if (snapshot == null) {
        actor.print(Caption.of("worldedit.snapshot.none-after", TextComponent.of(dateFormat.withZone(session.getTimeZone()).format(date))));
    } else {
        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 49 with CommandPermissions

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

the class SnapshotCommands method list.

@Command(name = "list", desc = "List snapshots")
@CommandPermissions("worldedit.snapshots.list")
void list(Actor actor, World world, @ArgFlag(name = 'p', desc = "Page of results to return", def = "1") int page) throws WorldEditException, IOException {
    LocalConfiguration config = we.getConfiguration();
    checkSnapshotsConfigured(config);
    if (config.snapshotRepo != null) {
        legacy.list(actor, world, page);
        return;
    }
    List<Snapshot> snapshots;
    try (Stream<Snapshot> snapshotStream = config.snapshotDatabase.getSnapshotsNewestFirst(world.getName())) {
        snapshots = snapshotStream.collect(toList());
    }
    if (!snapshots.isEmpty()) {
        actor.print(new SnapshotListBox(world.getName(), snapshots).create(page));
    } else {
        actor.print(Caption.of("worldedit.restore.none-for-specific-world", TextComponent.of(world.getName())));
        if (config.snapshotDatabase instanceof FileSystemSnapshotDatabase) {
            FileSystemSnapshotDatabase db = (FileSystemSnapshotDatabase) config.snapshotDatabase;
            Path root = db.getRoot();
            if (Files.isDirectory(root)) {
                WorldEdit.logger.info("No snapshots were found for world '" + world.getName() + "'; looked in " + root.toRealPath());
            } else {
                WorldEdit.logger.info("No snapshots were found for world '" + world.getName() + "'; " + root.toRealPath() + " is not a directory");
            }
        }
    }
}
Also used : Path(java.nio.file.Path) Snapshot(com.sk89q.worldedit.world.snapshot.experimental.Snapshot) FileSystemSnapshotDatabase(com.sk89q.worldedit.world.snapshot.experimental.fs.FileSystemSnapshotDatabase) LocalConfiguration(com.sk89q.worldedit.LocalConfiguration) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 50 with CommandPermissions

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

the class SnapshotCommands method before.

@Command(name = "before", desc = "Choose the nearest snapshot before a date")
@CommandPermissions("worldedit.snapshots.restore")
void before(Actor actor, World world, LocalSession session, @Arg(desc = "The soonest date that may be used") ZonedDateTime date) throws IOException {
    LocalConfiguration config = we.getConfiguration();
    checkSnapshotsConfigured(config);
    if (config.snapshotRepo != null) {
        legacy.before(actor, world, session, date);
        return;
    }
    Snapshot snapshot;
    try (Stream<Snapshot> snapshotStream = config.snapshotDatabase.getSnapshotsNewestFirst(world.getName())) {
        snapshot = snapshotStream.findFirst().orElse(null);
    }
    if (snapshot == null) {
        actor.print(Caption.of("worldedit.snapshot.none-before", TextComponent.of(dateFormat.withZone(session.getTimeZone()).format(date))));
    } else {
        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)

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