Search in sources :

Example 11 with FaweLimit

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);
            }
        }
    }
}
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

FaweLimit (com.fastasyncworldedit.core.limit.FaweLimit)11 CommandPermissions (com.sk89q.worldedit.command.util.CommandPermissions)6 Command (org.enginehub.piston.annotation.Command)6 BlockVector3 (com.sk89q.worldedit.math.BlockVector3)5 MultiClipboardHolder (com.fastasyncworldedit.core.extent.clipboard.MultiClipboardHolder)3 URIClipboardHolder (com.fastasyncworldedit.core.extent.clipboard.URIClipboardHolder)3 MaskTraverser (com.fastasyncworldedit.core.util.MaskTraverser)3 Confirm (com.sk89q.worldedit.command.util.annotation.Confirm)3 Preload (com.sk89q.worldedit.command.util.annotation.Preload)3 ScatterCommand (com.fastasyncworldedit.core.command.tool.brush.ScatterCommand)2 ReadOnlyClipboard (com.fastasyncworldedit.core.extent.clipboard.ReadOnlyClipboard)2 SnowSmoothBrush (com.sk89q.worldedit.command.tool.brush.SnowSmoothBrush)2 Logging (com.sk89q.worldedit.command.util.Logging)2 Player (com.sk89q.worldedit.entity.Player)2 Actor (com.sk89q.worldedit.extension.platform.Actor)2 BlockArrayClipboard (com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard)2 Mask (com.sk89q.worldedit.function.mask.Mask)2 RegionMask (com.sk89q.worldedit.function.mask.RegionMask)2 ForwardExtentCopy (com.sk89q.worldedit.function.operation.ForwardExtentCopy)2 ClipboardMask (com.sk89q.worldedit.internal.annotation.ClipboardMask)2