use of com.sk89q.worldedit.world.snapshot.experimental.fs.FileSystemSnapshotDatabase 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");
}
}
}
}
Aggregations