use of org.enginehub.piston.annotation.Command in project FastAsyncWorldEdit by IntellectualSites.
the class GenerationCommands method ores.
@Command(name = "/ores", desc = "Generates ores")
@CommandPermissions("worldedit.generation.ore")
@Logging(PLACEMENT)
@Preload(Preload.PreloadCheck.PRELOAD)
@Confirm(Confirm.Processor.REGION)
public void ores(Actor actor, LocalSession session, EditSession editSession, @Selection Region region, @Arg(desc = "Mask") Mask mask) throws WorldEditException {
new MaskTraverser(mask).setNewExtent(editSession);
editSession.addOres(region, mask);
actor.print(Caption.of("fawe.worldedit.visitor.visitor.block", editSession.getBlockChangeCount()));
}
use of org.enginehub.piston.annotation.Command in project FastAsyncWorldEdit by IntellectualSites.
the class GenerationCommands method blobBrush.
@Command(name = "/blob", aliases = { "/rock" }, desc = "Creates a distorted sphere")
@Logging(PLACEMENT)
@CommandPermissions("worldedit.generation.blob")
public int blobBrush(Actor actor, LocalSession session, EditSession editSession, @Arg(desc = "Pattern") Pattern pattern, @Arg(desc = "size", def = "5") double size, @Arg(desc = "radius", def = "5") Vector3 radius, @Arg(name = "roundness", desc = "roundness", def = "100") double sphericity, @Arg(desc = "double", def = "30") double frequency, @Arg(desc = "double", def = "50") double amplitude) throws WorldEditException {
double max = MathMan.max(radius.getX(), radius.getY(), radius.getZ());
worldEdit.checkMaxRadius(max);
BlockVector3 pos = session.getPlacementPosition(actor);
int affected = editSession.makeBlob(pos, pattern, size, frequency / 100, amplitude / 100, radius.divide(max), sphericity / 100);
if (actor instanceof Player) {
((Player) actor).findFreePosition();
}
actor.print(Caption.of("worldedit.sphere.created", TextComponent.of(affected)));
return affected;
}
use of org.enginehub.piston.annotation.Command in project FastAsyncWorldEdit by IntellectualSites.
the class HistorySubCommands method importdb.
@Command(name = "import", desc = "Import history into the database" + " - The time uses s, m, h, d, y.\n" + " - Import from disk: /history import")
@CommandPermissions("fawe.rollback.import")
@Confirm
public synchronized void importdb(Actor actor) throws WorldEditException {
File folder = MainUtil.getFile(Fawe.platform().getDirectory(), Settings.settings().PATHS.HISTORY);
if (folder.exists()) {
for (File worldFolder : Objects.requireNonNull(folder.listFiles())) {
if (worldFolder != null && worldFolder.isDirectory()) {
String worldName = worldFolder.getName();
World world = FaweAPI.getWorld(worldName);
if (world != null) {
for (File userFolder : worldFolder.listFiles()) {
if (!userFolder.isDirectory()) {
continue;
}
String userUUID = userFolder.getName();
try {
UUID uuid = UUID.fromString(userUUID);
for (File historyFile : userFolder.listFiles()) {
String name = historyFile.getName();
if (!name.endsWith(".bd")) {
continue;
}
RollbackOptimizedHistory rollback = new RollbackOptimizedHistory(world, uuid, Integer.parseInt(name.substring(0, name.length() - 3)));
SimpleChangeSetSummary summary = rollback.summarize(RegionWrapper.GLOBAL(), false);
if (summary != null) {
rollback.setDimensions(BlockVector3.at(summary.minX, world.getMinY(), summary.minZ), BlockVector3.at(summary.maxX, world.getMaxY(), summary.maxZ));
rollback.setTime(historyFile.lastModified());
RollbackDatabase db = DBHandler.IMP.getDatabase(world);
db.logEdit(rollback);
actor.print(TextComponent.of("Logging: " + historyFile));
}
}
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
}
}
}
}
actor.print(TextComponent.of("Done import!"));
}
}
use of org.enginehub.piston.annotation.Command in project FastAsyncWorldEdit by IntellectualSites.
the class HistorySubCommands method list.
@Command(name = "list", desc = "List your history")
@CommandPermissions("worldedit.history.list")
public void list(Player player, LocalSession session, RollbackDatabase database, Arguments arguments, @Arg(desc = "Player uuid/name") UUID other, @ArgFlag(name = 'p', desc = "Page to view.", def = "") Integer page) {
int index = session.getHistoryIndex();
List<Supplier<? extends ChangeSet>> history = Lists.transform(session.getHistory(), (Function<ChangeSet, Supplier<ChangeSet>>) input -> () -> input);
Location origin = player.getLocation();
String pageCommand = "/" + arguments.get().replaceAll("-p [0-9]+", "").trim();
Reference<PaginationBox> cached = player.getMeta(pageCommand);
PaginationBox pages = cached == null ? null : cached.get();
if (page == null || pages == null) {
pages = list(database, pageCommand, history, origin.toBlockPoint());
page = 1;
}
player.print(pages.create(page));
}
use of org.enginehub.piston.annotation.Command in project FastAsyncWorldEdit by IntellectualSites.
the class SelectionCommands method distr.
@Command(name = "/distr", desc = "Get the distribution of blocks in the selection")
@CommandPermissions("worldedit.analysis.distr")
public void distr(Actor actor, World world, LocalSession session, // FAWE start > add extent to RegionVisitor to allow chunk preloading
EditSession editSession, // FAWE end
@Switch(name = 'c', desc = "Get the distribution of the clipboard instead") boolean clipboardDistr, @Switch(name = 'd', desc = "Separate blocks by state") boolean separateStates, @ArgFlag(name = 'p', desc = "Gets page from a previous distribution.") Integer page) throws WorldEditException {
List<Countable<BlockState>> distribution;
if (page == null) {
if (clipboardDistr) {
// throws if missing
Clipboard clipboard = session.getClipboard().getClipboard();
BlockDistributionCounter count = new BlockDistributionCounter(clipboard, separateStates);
// FAWE start > add extent to RegionVisitor to allow chunk preloading
RegionVisitor visitor = new RegionVisitor(clipboard.getRegion(), count, editSession);
// FAWE end
Operations.completeBlindly(visitor);
distribution = count.getDistribution();
} else {
distribution = editSession.getBlockDistribution(session.getSelection(world), separateStates);
}
session.setLastDistribution(distribution);
page = 1;
} else {
distribution = session.getLastDistribution();
if (distribution == null) {
actor.print(Caption.of("worldedit.distr.no-previous"));
return;
}
}
if (distribution.isEmpty()) {
// *Should* always be false
actor.print(Caption.of("worldedit.distr.no-blocks"));
return;
}
BlockDistributionResult res = new BlockDistributionResult(distribution, separateStates);
if (!actor.isPlayer()) {
res.formatForConsole();
}
actor.print(res.create(page));
}
Aggregations