Search in sources :

Example 1 with NullRelighter

use of com.fastasyncworldedit.core.extent.processor.lighting.NullRelighter 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);
            }
        }
    }
}
Also used : Player(com.sk89q.worldedit.entity.Player) FaweLimit(com.fastasyncworldedit.core.limit.FaweLimit) Preloader(com.fastasyncworldedit.core.queue.implementation.preloader.Preloader) AbstractChangeSet(com.fastasyncworldedit.core.history.changeset.AbstractChangeSet) NullRelighter(com.fastasyncworldedit.core.extent.processor.lighting.NullRelighter) IOException(java.io.IOException)

Aggregations

NullRelighter (com.fastasyncworldedit.core.extent.processor.lighting.NullRelighter)1 AbstractChangeSet (com.fastasyncworldedit.core.history.changeset.AbstractChangeSet)1 FaweLimit (com.fastasyncworldedit.core.limit.FaweLimit)1 Preloader (com.fastasyncworldedit.core.queue.implementation.preloader.Preloader)1 Player (com.sk89q.worldedit.entity.Player)1 IOException (java.io.IOException)1