Search in sources :

Example 6 with Snapshot

use of com.sk89q.worldedit.world.snapshot.Snapshot 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)

Aggregations

LocalConfiguration (com.sk89q.worldedit.LocalConfiguration)6 Snapshot (com.sk89q.worldedit.world.snapshot.Snapshot)6 MissingWorldException (com.sk89q.worldedit.world.storage.MissingWorldException)6 InvalidSnapshotException (com.sk89q.worldedit.world.snapshot.InvalidSnapshotException)2 File (java.io.File)2 IOException (java.io.IOException)2 Region (com.sk89q.worldedit.regions.Region)1 DataException (com.sk89q.worldedit.world.DataException)1 SnapshotRestore (com.sk89q.worldedit.world.snapshot.SnapshotRestore)1 ChunkStore (com.sk89q.worldedit.world.storage.ChunkStore)1