Search in sources :

Example 21 with LocalConfiguration

use of com.sk89q.worldedit.LocalConfiguration in project FastAsyncWorldEdit by IntellectualSites.

the class LegacySnapshotCommands method use.

void use(Actor actor, World world, LocalSession session, String name) {
    LocalConfiguration config = we.getConfiguration();
    // Want the latest snapshot?
    if (name.equalsIgnoreCase("latest")) {
        try {
            Snapshot snapshot = config.snapshotRepo.getDefaultSnapshot(world.getName());
            if (snapshot != null) {
                session.setSnapshot(null);
                actor.print(Caption.of("worldedit.snapshot.use.newest"));
            } else {
                actor.print(Caption.of("worldedit.restore.none-found"));
            }
        } catch (MissingWorldException ex) {
            actor.print(Caption.of("worldedit.restore.none-for-world"));
        }
    } else {
        try {
            session.setSnapshot(config.snapshotRepo.getSnapshot(name));
            actor.print(Caption.of("worldedit.snapshot.use", TextComponent.of(name)));
        } catch (InvalidSnapshotException e) {
            actor.print(Caption.of("worldedit.restore.not-available"));
        }
    }
}
Also used : Snapshot(com.sk89q.worldedit.world.snapshot.Snapshot) InvalidSnapshotException(com.sk89q.worldedit.world.snapshot.InvalidSnapshotException) LocalConfiguration(com.sk89q.worldedit.LocalConfiguration) MissingWorldException(com.sk89q.worldedit.world.storage.MissingWorldException)

Example 22 with LocalConfiguration

use of com.sk89q.worldedit.LocalConfiguration in project FastAsyncWorldEdit by IntellectualSites.

the class LegacySnapshotCommands method sel.

void sel(Actor actor, World world, LocalSession session, int index) {
    LocalConfiguration config = we.getConfiguration();
    if (index < 1) {
        actor.print(Caption.of("worldedit.snapshot.index-above-0"));
        return;
    }
    try {
        List<Snapshot> snapshots = config.snapshotRepo.getSnapshots(true, world.getName());
        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;
        }
        session.setSnapshot(snapshot);
        actor.print(Caption.of("worldedit.snapshot.use", TextComponent.of(snapshot.getName())));
    } catch (MissingWorldException e) {
        actor.print(Caption.of("worldedit.restore.none-for-world"));
    }
}
Also used : Snapshot(com.sk89q.worldedit.world.snapshot.Snapshot) LocalConfiguration(com.sk89q.worldedit.LocalConfiguration) MissingWorldException(com.sk89q.worldedit.world.storage.MissingWorldException)

Example 23 with LocalConfiguration

use of com.sk89q.worldedit.LocalConfiguration in project FastAsyncWorldEdit by IntellectualSites.

the class LegacySnapshotCommands method list.

void list(Actor actor, World world, int page) throws WorldEditException {
    LocalConfiguration config = we.getConfiguration();
    try {
        List<Snapshot> snapshots = config.snapshotRepo.getSnapshots(true, world.getName());
        if (!snapshots.isEmpty()) {
            actor.print(new SnapshotListBox(world.getName(), snapshots).create(page));
        } else {
            actor.print(Caption.of("worldedit.restore.none-found-console"));
            // Okay, let's toss some debugging information!
            File dir = config.snapshotRepo.getDirectory();
            try {
                WorldEdit.logger.info("WorldEdit found no snapshots: looked in: " + dir.getCanonicalPath());
            } catch (IOException e) {
                WorldEdit.logger.info("WorldEdit found no snapshots: looked in " + "(NON-RESOLVABLE PATH - does it exist?): " + dir.getPath());
            }
        }
    } catch (MissingWorldException ex) {
        actor.print(Caption.of("worldedit.restore.none-for-world"));
    }
}
Also used : Snapshot(com.sk89q.worldedit.world.snapshot.Snapshot) IOException(java.io.IOException) LocalConfiguration(com.sk89q.worldedit.LocalConfiguration) File(java.io.File) MissingWorldException(com.sk89q.worldedit.world.storage.MissingWorldException)

Example 24 with LocalConfiguration

use of com.sk89q.worldedit.LocalConfiguration 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 25 with LocalConfiguration

use of com.sk89q.worldedit.LocalConfiguration 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

LocalConfiguration (com.sk89q.worldedit.LocalConfiguration)31 CommandPermissions (com.sk89q.worldedit.command.util.CommandPermissions)20 Command (org.enginehub.piston.annotation.Command)20 File (java.io.File)12 IOException (java.io.IOException)9 URI (java.net.URI)7 URIClipboardHolder (com.fastasyncworldedit.core.extent.clipboard.URIClipboardHolder)6 Snapshot (com.sk89q.worldedit.world.snapshot.Snapshot)6 Snapshot (com.sk89q.worldedit.world.snapshot.experimental.Snapshot)6 MissingWorldException (com.sk89q.worldedit.world.storage.MissingWorldException)6 MultiClipboardHolder (com.fastasyncworldedit.core.extent.clipboard.MultiClipboardHolder)5 ClipboardHolder (com.sk89q.worldedit.session.ClipboardHolder)4 Logging (com.sk89q.worldedit.command.util.Logging)3 ClipboardFormat (com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat)3 Component (com.sk89q.worldedit.util.formatting.text.Component)3 TextComponent (com.sk89q.worldedit.util.formatting.text.TextComponent)3 TranslatableComponent (com.sk89q.worldedit.util.formatting.text.TranslatableComponent)3 Region (com.sk89q.worldedit.regions.Region)2 InvalidSnapshotException (com.sk89q.worldedit.world.snapshot.InvalidSnapshotException)2 URL (java.net.URL)2