diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitChunkCoordinator.java b/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitChunkCoordinator.java index 2ed483ee1..6a38c861f 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitChunkCoordinator.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitChunkCoordinator.java @@ -92,9 +92,9 @@ public final class BukkitChunkCoordinator extends ChunkCoordinator { @Assisted final @NonNull Collection requestedChunks, @Assisted final @NonNull Runnable whenDone, @Assisted final @NonNull Consumer throwableConsumer, - @Assisted final boolean unloadAfter, + @Assisted("unloadAfter") final boolean unloadAfter, @Assisted final @NonNull Collection progressSubscribers, - @Assisted final boolean forceSync + @Assisted("forceSync") final boolean forceSync ) { this.requestedChunks = new LinkedBlockingQueue<>(requestedChunks); this.availableChunks = new LinkedBlockingQueue<>(); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitQueueCoordinator.java b/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitQueueCoordinator.java index aadc888fd..a862702ef 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitQueueCoordinator.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitQueueCoordinator.java @@ -235,6 +235,7 @@ public class BukkitQueueCoordinator extends BasicQueueCoordinator { .withConsumer(consumer) .unloadAfter(isUnloadAfter()) .withProgressSubscribers(getProgressSubscribers()) + .forceSync(isForceSync()) .build(); return super.enqueue(); } diff --git a/Core/src/main/java/com/plotsquared/core/inject/factory/ChunkCoordinatorFactory.java b/Core/src/main/java/com/plotsquared/core/inject/factory/ChunkCoordinatorFactory.java index 750d81894..5be3a5421 100644 --- a/Core/src/main/java/com/plotsquared/core/inject/factory/ChunkCoordinatorFactory.java +++ b/Core/src/main/java/com/plotsquared/core/inject/factory/ChunkCoordinatorFactory.java @@ -25,6 +25,7 @@ */ package com.plotsquared.core.inject.factory; +import com.google.inject.assistedinject.Assisted; import com.plotsquared.core.queue.ChunkCoordinator; import com.plotsquared.core.queue.subscriber.ProgressSubscriber; import com.sk89q.worldedit.math.BlockVector2; @@ -44,8 +45,9 @@ public interface ChunkCoordinatorFactory { final @NonNull Collection requestedChunks, final @NonNull Runnable whenDone, final @NonNull Consumer throwableConsumer, - final boolean unloadAfter, - final @NonNull Collection progressSubscribers + @Assisted("unloadAfter") final boolean unloadAfter, + final @NonNull Collection progressSubscribers, + @Assisted("forceSync") final boolean forceSync ); } diff --git a/Core/src/main/java/com/plotsquared/core/queue/ChunkCoordinatorBuilder.java b/Core/src/main/java/com/plotsquared/core/queue/ChunkCoordinatorBuilder.java index f36379db7..49e8de209 100644 --- a/Core/src/main/java/com/plotsquared/core/queue/ChunkCoordinatorBuilder.java +++ b/Core/src/main/java/com/plotsquared/core/queue/ChunkCoordinatorBuilder.java @@ -58,6 +58,7 @@ public class ChunkCoordinatorBuilder { private long maxIterationTime = Settings.QUEUE.MAX_ITERATION_TIME; // A little over 1 tick; private int initialBatchSize = Settings.QUEUE.INITIAL_BATCH_SIZE; private boolean unloadAfter = true; + private boolean forceSync = false; @Inject public ChunkCoordinatorBuilder(@NonNull ChunkCoordinatorFactory chunkCoordinatorFactory) { @@ -197,6 +198,18 @@ public class ChunkCoordinatorBuilder { return this; } + /** + * Set whether the chunks coordinator should be forced to be synchronous. This is not necessarily synchronous to the server, + * and simply effectively makes {@link ChunkCoordinator#start()} ()} a blocking operation. + * + * @param forceSync force sync or not + * @since TODO + */ + public @NonNull ChunkCoordinatorBuilder forceSync(final boolean forceSync) { + this.forceSync = forceSync; + return this; + } + public @NonNull ChunkCoordinatorBuilder withProgressSubscriber(ProgressSubscriber progressSubscriber) { this.progressSubscribers.add(progressSubscriber); return this; @@ -227,7 +240,8 @@ public class ChunkCoordinatorBuilder { this.whenDone, this.throwableConsumer, this.unloadAfter, - this.progressSubscribers + this.progressSubscribers, + this.forceSync ); } diff --git a/Core/src/main/java/com/plotsquared/core/queue/QueueCoordinator.java b/Core/src/main/java/com/plotsquared/core/queue/QueueCoordinator.java index a53158d1e..72ab65f77 100644 --- a/Core/src/main/java/com/plotsquared/core/queue/QueueCoordinator.java +++ b/Core/src/main/java/com/plotsquared/core/queue/QueueCoordinator.java @@ -40,14 +40,12 @@ import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; - -import java.util.concurrent.atomic.AtomicBoolean; - import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; import java.util.List; import java.util.Set; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Consumer; public abstract class QueueCoordinator { @@ -119,7 +117,8 @@ public abstract class QueueCoordinator { public abstract void setModified(long modified); /** - * Returns true if the queue should be forced to be synchronous when enqueued. + * Returns true if the queue should be forced to be synchronous when enqueued. This is not necessarily synchronous to the + * server, and simply effectively makes {@link QueueCoordinator#enqueue()} a blocking operation. * * @return is force sync */ @@ -128,7 +127,8 @@ public abstract class QueueCoordinator { } /** - * Set whether the queue should be forced to be synchronous + * Set whether the queue should be forced to be synchronous. This is not necessarily synchronous to the server, and simply + * effectively makes {@link QueueCoordinator#enqueue()} a blocking operation. * * @param forceSync force sync or not */