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"));
}
}
}
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"));
}
}
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"));
}
}
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())));
}
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"));
}
Aggregations