mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-10 06:28:36 +00:00
Allow "post processing" of chunks (#658)
* begin allowing "post processing" of chunks - restores legacy capability to continue saving edits in the background after sending the chunks - speeds up the edit clientside - nail in the coffin of the terrible and staticly coded coreedit - We should totally make IronGolem work so Core* is no longer used by anyone * begin allowing background history saving * Handle post processors in queues properly * Use futures for postprocessing so we're not waiting for them needlessly * better use of closed boolean * Reword
This commit is contained in:
@ -59,7 +59,6 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor {
|
||||
if (closed) {
|
||||
return;
|
||||
}
|
||||
closed = true;
|
||||
waitingAsync.incrementAndGet();
|
||||
TaskManager.IMP.async(() -> {
|
||||
waitingAsync.decrementAndGet();
|
||||
@ -97,8 +96,8 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor {
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
if (!closed) {
|
||||
closed = true;
|
||||
flush();
|
||||
closed = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -204,6 +203,11 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor {
|
||||
return set;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Future<IChunkSet> postProcessSet(final IChunk chunk, final IChunkGet get,final IChunkSet set) {
|
||||
return (Future<IChunkSet>) addWriteTask(() -> processSet(chunk, get, set));
|
||||
}
|
||||
|
||||
public abstract void addTileCreate(CompoundTag tag);
|
||||
|
||||
public abstract void addTileRemove(CompoundTag tag);
|
||||
|
@ -10,6 +10,8 @@ import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
public class HeightBoundExtent extends FaweRegionExtent {
|
||||
|
||||
@ -51,4 +53,9 @@ public class HeightBoundExtent extends FaweRegionExtent {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Future<IChunkSet> postProcessSet(IChunk chunk, IChunkGet get, IChunkSet set) {
|
||||
return CompletableFuture.completedFuture(set);
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import com.sk89q.worldedit.regions.RegionIntersection;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
public class MultiRegionExtent extends FaweRegionExtent {
|
||||
|
||||
@ -86,4 +87,9 @@ public class MultiRegionExtent extends FaweRegionExtent {
|
||||
public IChunkSet processSet(IChunk chunk, IChunkGet get, IChunkSet set) {
|
||||
return intersection.processSet(chunk, get, set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Future<IChunkSet> postProcessSet(IChunk chunk, IChunkGet get, IChunkSet set) {
|
||||
return intersection.postProcessSet(chunk, get, set);
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Future;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
//todo This should be removed in favor of com.sk89q.worldedit.extent.NullExtent
|
||||
@ -340,6 +341,11 @@ public class NullExtent extends FaweRegionExtent implements IBatchProcessor {
|
||||
throw reason;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Future<IChunkSet> postProcessSet(IChunk chunk, IChunkGet get, IChunkSet set) {
|
||||
throw reason;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processGet(int chunkX, int chunkZ) {
|
||||
throw reason;
|
||||
|
@ -9,6 +9,7 @@ import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
public class SingleRegionExtent extends FaweRegionExtent {
|
||||
|
||||
@ -44,6 +45,11 @@ public class SingleRegionExtent extends FaweRegionExtent {
|
||||
return region.processSet(chunk, get, set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Future<IChunkSet> postProcessSet(IChunk chunk, IChunkGet get, IChunkSet set) {
|
||||
return region.postProcessSet(chunk, get, set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processGet(int chunkX, int chunkZ) {
|
||||
return region.containsChunk(chunkX, chunkZ);
|
||||
|
Reference in New Issue
Block a user