Search in sources :

Example 6 with MissingWorldException

use of com.sk89q.worldedit.world.storage.MissingWorldException in project FastAsyncWorldEdit by IntellectualSites.

the class LegacySnapshotCommands method before.

void before(Actor actor, World world, LocalSession session, ZonedDateTime date) {
    LocalConfiguration config = we.getConfiguration();
    try {
        Snapshot snapshot = config.snapshotRepo.getSnapshotBefore(date, world.getName());
        if (snapshot == null) {
            actor.print(Caption.of("worldedit.snapshot.none-before", TextComponent.of(dateFormat.withZone(session.getTimeZone()).format(date))));
        } else {
            session.setSnapshot(snapshot);
            actor.print(Caption.of("worldedit.snapshot.use", TextComponent.of(snapshot.getName())));
        }
    } catch (MissingWorldException ex) {
        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 7 with MissingWorldException

use of com.sk89q.worldedit.world.storage.MissingWorldException 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

MissingWorldException (com.sk89q.worldedit.world.storage.MissingWorldException)7 LocalConfiguration (com.sk89q.worldedit.LocalConfiguration)6 Snapshot (com.sk89q.worldedit.world.snapshot.Snapshot)6 File (java.io.File)3 InvalidSnapshotException (com.sk89q.worldedit.world.snapshot.InvalidSnapshotException)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 FilenameFilter (java.io.FilenameFilter)1 ZoneOffset (java.time.ZoneOffset)1 ZonedDateTime (java.time.ZonedDateTime)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 Collections (java.util.Collections)1 List (java.util.List)1 Locale (java.util.Locale)1 Nullable (javax.annotation.Nullable)1