use of com.sk89q.worldedit.command.util.Logging in project FastAsyncWorldEdit by IntellectualSites.
the class SelectionCommands method shift.
@Command(name = "/shift", desc = "Shift the selection area")
@Logging(REGION)
@CommandPermissions("worldedit.selection.shift")
public void shift(Actor actor, World world, LocalSession session, @Arg(desc = "Amount to shift the selection by") int amount, @Arg(desc = "Direction to contract", def = Direction.AIM) @MultiDirection List<BlockVector3> direction) throws WorldEditException {
try {
Region region = session.getSelection(world);
for (BlockVector3 dir : direction) {
region.shift(dir.multiply(amount));
}
session.getRegionSelector(world).learnChanges();
session.getRegionSelector(world).explainRegionAdjust(actor, session);
actor.print(Caption.of("worldedit.shift.shifted"));
} catch (RegionOperationException e) {
actor.printError(TextComponent.of(e.getMessage()));
}
}
use of com.sk89q.worldedit.command.util.Logging in project FastAsyncWorldEdit by IntellectualSites.
the class SelectionCommands method inset.
@Command(name = "/inset", desc = "Inset the selection area")
@Logging(REGION)
@CommandPermissions("worldedit.selection.inset")
public void inset(Actor actor, World world, LocalSession session, @Arg(desc = "Amount to contract the selection by in all directions") int amount, @Switch(name = 'h', desc = "Only contract horizontally") boolean onlyHorizontal, @Switch(name = 'v', desc = "Only contract vertically") boolean onlyVertical) throws WorldEditException {
Region region = session.getSelection(world);
region.contract(getChangesForEachDir(amount, onlyHorizontal, onlyVertical));
session.getRegionSelector(world).learnChanges();
session.getRegionSelector(world).explainRegionAdjust(actor, session);
actor.print(Caption.of("worldedit.inset.inset"));
}
use of com.sk89q.worldedit.command.util.Logging in project FastAsyncWorldEdit by IntellectualSites.
the class SnapshotUtilCommands method restore.
@Command(name = "restore", aliases = { "/restore" }, desc = "Restore the selection from a snapshot")
@Logging(REGION)
@CommandPermissions("worldedit.snapshots.restore")
public void restore(Actor actor, World world, LocalSession session, EditSession editSession, @Arg(name = "snapshot", desc = "The snapshot to restore", def = "") String snapshotName, // FAWE start - biome and entity restore
@Switch(name = 'b', desc = "If biomes should be restored. If restoring from pre-1.15 to 1.15+, biomes may not be " + "exactly the same due to 3D biomes.") boolean restoreBiomes, @Switch(name = 'e', desc = "If entities should be restored. Will cause issues with duplicate entities if all " + "original entities were not removed.") boolean restoreEntities) throws // FAWE end
WorldEditException, IOException {
LocalConfiguration config = we.getConfiguration();
checkSnapshotsConfigured(config);
if (config.snapshotRepo != null) {
// FAWE start - biome and entity restore
legacy.restore(actor, world, session, editSession, snapshotName, restoreBiomes, restoreEntities);
// FAWE end
return;
}
Region region = session.getSelection(world);
Snapshot snapshot;
if (snapshotName != null) {
URI uri = resolveSnapshotName(config, snapshotName);
Optional<Snapshot> snapOpt = config.snapshotDatabase.getSnapshot(uri);
if (!snapOpt.isPresent()) {
actor.print(Caption.of("worldedit.restore.not-available"));
return;
}
snapshot = snapOpt.get();
} else {
snapshot = session.getSnapshotExperimental();
}
// No snapshot set?
if (snapshot == null) {
try (Stream<Snapshot> snapshotStream = config.snapshotDatabase.getSnapshotsNewestFirst(world.getName())) {
snapshot = snapshotStream.findFirst().orElse(null);
}
if (snapshot == null) {
actor.print(Caption.of("worldedit.restore.none-for-specific-world", TextComponent.of(world.getName())));
return;
}
}
actor.print(Caption.of("worldedit.restore.loaded", TextComponent.of(snapshot.getInfo().getDisplayName())));
try {
// Restore snapshot
// FAWE start - biome and entity restore
SnapshotRestore restore = new SnapshotRestore(snapshot, editSession, region, restoreBiomes, restoreEntities);
// FAWE end
restore.restore();
if (restore.hadTotalFailure()) {
String error = restore.getLastErrorMessage();
if (!restore.getMissingChunks().isEmpty()) {
actor.print(Caption.of("worldedit.restore.chunk-not-present"));
} else if (error != null) {
actor.print(Caption.of("worldedit.restore.block-place-failed"));
actor.print(Caption.of("worldedit.restore.block-place-error", TextComponent.of(error)));
} else {
actor.print(Caption.of("worldedit.restore.chunk-load-failed"));
}
} else {
actor.print(Caption.of("worldedit.restore.restored", TextComponent.of(restore.getMissingChunks().size()), TextComponent.of(restore.getErrorChunks().size())));
}
} finally {
try {
snapshot.close();
} catch (IOException ignored) {
}
}
}
use of com.sk89q.worldedit.command.util.Logging in project FastAsyncWorldEdit by IntellectualSites.
the class UtilityCommands method fill.
@Command(name = "/fill", desc = "Fill a hole")
@CommandPermissions("worldedit.fill")
@Logging(PLACEMENT)
public int fill(Actor actor, LocalSession session, EditSession editSession, @Arg(desc = "The blocks to fill with") Pattern pattern, // FAWE start - we take an expression over a double
@Arg(desc = "The radius to fill in") Expression radiusExp, // FAWE end
@Arg(desc = "The depth to fill", def = "1") int depth, @Arg(desc = "The direction to move", def = "down") @Direction BlockVector3 direction) throws WorldEditException, EvaluationException {
// FAWE start
double radius = radiusExp.evaluate();
// FAWE end
radius = Math.max(1, radius);
we.checkMaxRadius(radius);
depth = Math.max(1, depth);
BlockVector3 pos = session.getPlacementPosition(actor);
int affected = editSession.fillDirection(pos, pattern, radius, depth, direction);
actor.print(Caption.of("worldedit.fill.created", TextComponent.of(affected)));
return affected;
}
use of com.sk89q.worldedit.command.util.Logging in project FastAsyncWorldEdit by IntellectualSites.
the class UtilityCommands method snow.
@Command(name = "snow", aliases = { "/snow" }, desc = "Simulates snow")
@CommandPermissions("worldedit.snow")
@Logging(PLACEMENT)
public int snow(Actor actor, LocalSession session, EditSession editSession, @Arg(desc = "The radius of the cylinder to snow in", def = "10") double size, @Arg(desc = "The height of the cylinder to snow in", def = HeightConverter.DEFAULT_VALUE) @VertHeight int height, @Switch(name = 's', desc = "Stack snow layers") boolean stack) throws WorldEditException {
size = Math.max(1, size);
height = Math.max(1, height);
we.checkMaxRadius(size);
BlockVector3 position = session.getPlacementPosition(actor);
CylinderRegion region = new CylinderRegion(position, Vector2.at(size, size), position.getBlockY() - height, position.getBlockY() + height);
int affected = editSession.simulateSnow(region, stack);
actor.print(Caption.of("worldedit.snow.created", TextComponent.of(affected)));
return affected;
}
Aggregations