use of com.sk89q.worldedit.util.Countable in project FastAsyncWorldEdit by IntellectualSites.
the class BlockDistributionCounter method apply.
@Override
public boolean apply(BlockVector3 position) throws WorldEditException {
BlockState blk = extent.getBlock(position);
if (!separateStates) {
blk = blk.getBlockType().getDefaultState();
}
if (map.containsKey(blk)) {
map.get(blk).increment();
} else {
Countable<BlockState> c = new Countable<>(blk, 1);
map.put(blk, c);
distribution.add(c);
}
return true;
}
use of com.sk89q.worldedit.util.Countable in project FastAsyncWorldEdit by IntellectualSites.
the class HistorySubCommands method distr.
@Command(name = "distr", aliases = { "distribution" }, desc = "View block distribution for an edit")
@CommandPermissions("worldedit.history.distr")
public void distr(Player player, LocalSession session, RollbackDatabase database, Arguments arguments, @Arg(desc = "Player uuid/name") UUID other, @Arg(desc = "edit index") Integer index, @ArgFlag(name = 'p', desc = "Page to view.", def = "") Integer page) throws ExecutionException, InterruptedException {
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) {
RollbackOptimizedHistory edit = database.getEdit(other, index).get();
SimpleChangeSetSummary summary = edit.summarize(RegionWrapper.GLOBAL(), false);
if (summary != null) {
List<Countable<BlockState>> distr = summary.getBlockDistributionWithData();
SelectionCommands.BlockDistributionResult distrPages = new SelectionCommands.BlockDistributionResult(distr, true, pageCommand);
pages = new PaginationBox.MergedPaginationBox("Block Distribution", pageCommand, pages, distrPages);
player.setMeta(pageCommand, new SoftReference<>(pages));
}
page = 1;
}
if (pages == null) {
player.print(Caption.of("fawe.worldedit.history.distr.summary_null"));
} else {
player.print(pages.create(page));
}
}
Aggregations