use of com.fastasyncworldedit.core.limit.FaweLimit in project FastAsyncWorldEdit by IntellectualSites.
the class EditSession method flushQueue.
// FAWE start
/**
* Finish off the queue.
*/
public void flushQueue() {
Operations.completeBlindly(commit());
// Check fails
FaweLimit used = getLimitUsed();
if (used.MAX_FAILS > 0) {
if (used.MAX_CHANGES > 0 || used.MAX_ENTITIES > 0) {
actor.print(Caption.of("fawe.error.worldedit.some.fails", used.MAX_FAILS));
} else if (new ExtentTraverser<>(getExtent()).findAndGet(FaweRegionExtent.class) != null) {
actor.print(Caption.of("fawe.cancel.reason.outside.region"));
} else {
actor.print(Caption.of("fawe.cancel.reason.outside.level"));
}
}
if (wnaMode) {
getWorld().flush();
}
// Reset limit
limit.set(originalLimit);
try {
if (relighter != null && !(relighter instanceof NullRelighter)) {
// Don't relight twice!
if (!relighter.isFinished() && relighter.getLock().tryLock()) {
try {
if (Settings.settings().LIGHTING.REMOVE_FIRST) {
relighter.removeAndRelight(true);
} else {
relighter.fixLightingSafe(true);
}
} finally {
relighter.getLock().unlock();
}
}
}
} catch (Throwable e) {
actor.print(Caption.of("fawe.error.lighting"));
e.printStackTrace();
}
// Cancel any preloader associated with the actor if present
if (getActor() instanceof Player) {
Preloader preloader = Fawe.platform().getPreloader(false);
if (preloader != null) {
preloader.cancel(getActor());
}
}
// Enqueue it
if (getChangeSet() != null) {
if (Settings.settings().HISTORY.COMBINE_STAGES) {
((AbstractChangeSet) getChangeSet()).closeAsync();
} else {
try {
getChangeSet().close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
}
Aggregations