use of com.sk89q.worldedit.command.util.CommandPermissions in project FastAsyncWorldEdit by IntellectualSites.
the class RegionCommands method wer.
@Command(name = "/wer", aliases = { "wer", "worldeditregion", "/worldeditregion", "select", "/select" }, desc = "Select your current allowed region", descFooter = "Select your current allowed region")
@CommandPermissions("fawe.worldeditregion")
public void wer(Player player) throws WorldEditException {
final Region region = player.getLargestRegion();
if (region == null) {
player.print(Caption.of("fawe.error.no.region"));
} else {
player.setSelection(region);
player.print(Caption.of("fawe.info.set.region"));
}
}
use of com.sk89q.worldedit.command.util.CommandPermissions in project FastAsyncWorldEdit by IntellectualSites.
the class ScriptingCommands method executeLast.
@Command(name = ".s", aliases = { "/.s" }, desc = "Execute last CraftScript")
@CommandPermissions("worldedit.scripting.execute")
@Logging(ALL)
public void executeLast(Player player, LocalSession session, @Arg(desc = "Arguments to the CraftScript", def = "", variable = true) List<String> args) throws WorldEditException {
String lastScript = session.getLastScript();
if (!player.hasPermission("worldedit.scripting.execute." + lastScript)) {
player.print(Caption.of("worldedit.execute.script-permissions"));
return;
}
if (lastScript == null) {
player.print(Caption.of("worldedit.executelast.no-script"));
return;
}
File dir = worldEdit.getWorkingDirectoryPath(worldEdit.getConfiguration().scriptsDir).toFile();
File f = worldEdit.getSafeOpenFile(player, dir, lastScript, "js", "js");
worldEdit.runScript(player, f, Stream.concat(Stream.of(lastScript), args.stream()).toArray(String[]::new));
}
use of com.sk89q.worldedit.command.util.CommandPermissions in project FastAsyncWorldEdit by IntellectualSites.
the class ScriptingCommands method execute.
@Command(name = "cs", aliases = { "/cs" }, desc = "Execute a CraftScript")
@CommandPermissions("worldedit.scripting.execute")
@Logging(ALL)
public void execute(Player player, LocalSession session, @Arg(desc = "Filename of the CraftScript to load") String filename, @Arg(desc = "Arguments to the CraftScript", def = "", variable = true) List<String> args) throws WorldEditException {
if (!player.hasPermission("worldedit.scripting.execute." + filename)) {
player.print(Caption.of("worldedit.execute.script-permissions"));
return;
}
session.setLastScript(filename);
File dir = worldEdit.getWorkingDirectoryPath(worldEdit.getConfiguration().scriptsDir).toFile();
File f = worldEdit.getSafeOpenFile(player, dir, filename, "js", "js");
worldEdit.runScript(player, f, Stream.concat(Stream.of(filename), args.stream()).toArray(String[]::new));
}
use of com.sk89q.worldedit.command.util.CommandPermissions in project FastAsyncWorldEdit by IntellectualSites.
the class SnapshotCommands method use.
@Command(name = "use", desc = "Choose a snapshot to use")
@CommandPermissions("worldedit.snapshots.restore")
void use(Actor actor, World world, LocalSession session, @Arg(desc = "Snapshot to use") String name) throws IOException {
LocalConfiguration config = we.getConfiguration();
checkSnapshotsConfigured(config);
if (config.snapshotRepo != null) {
legacy.use(actor, world, session, name);
return;
}
// Want the latest snapshot?
if (name.equalsIgnoreCase("latest")) {
Snapshot snapshot;
try (Stream<Snapshot> snapshotStream = config.snapshotDatabase.getSnapshotsNewestFirst(world.getName())) {
snapshot = snapshotStream.findFirst().orElse(null);
}
if (snapshot != null) {
if (session.getSnapshotExperimental() != null) {
session.getSnapshotExperimental().close();
}
session.setSnapshot(null);
actor.print(Caption.of("worldedit.snapshot.use.newest"));
} else {
actor.print(Caption.of("worldedit.restore.none-for-world"));
}
} else {
URI uri = resolveSnapshotName(config, name);
Optional<Snapshot> snapshot = config.snapshotDatabase.getSnapshot(uri);
if (snapshot.isPresent()) {
if (session.getSnapshotExperimental() != null) {
session.getSnapshotExperimental().close();
}
session.setSnapshotExperimental(snapshot.get());
actor.print(Caption.of("worldedit.snapshot.use", TextComponent.of(name)));
} else {
actor.print(Caption.of("worldedit.restore.not-available"));
}
}
}
use of com.sk89q.worldedit.command.util.CommandPermissions 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