use of com.sk89q.worldedit.function.block.BlockDistributionCounter 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