use of com.fastasyncworldedit.core.history.changeset.SimpleChangeSetSummary 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 com.fastasyncworldedit.core.history.changeset.SimpleChangeSetSummary in project FastAsyncWorldEdit by IntellectualSites.
the class RollbackOptimizedHistory method summarizeShallow.
@Override
protected SimpleChangeSetSummary summarizeShallow() {
SimpleChangeSetSummary summary = super.summarizeShallow();
summary.minX = this.minX;
summary.minZ = this.minZ;
summary.maxX = this.maxX;
summary.maxZ = this.maxZ;
return summary;
}
use of com.fastasyncworldedit.core.history.changeset.SimpleChangeSetSummary 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));
}
}
use of com.fastasyncworldedit.core.history.changeset.SimpleChangeSetSummary in project FastAsyncWorldEdit by IntellectualSites.
the class ArrayListHistory method summarize.
// FAWE start
@Override
public ChangeSetSummary summarize(Region region, boolean shallow) {
SimpleChangeSetSummary summary = new SimpleChangeSetSummary();
for (Change change : changes) {
if (change instanceof BlockChange) {
BlockChange blockChange = (BlockChange) change;
BlockVector3 pos = blockChange.getPosition();
summary.add(pos.getX(), pos.getZ(), blockChange.getCurrent().getOrdinal());
}
}
return summary;
}
Aggregations