Package com.plotsquared.core.queue
Class ChunkCoordinatorBuilder
java.lang.Object
com.plotsquared.core.queue.ChunkCoordinatorBuilder
Builds a
ChunkCoordinator
instance-
Constructor Summary
ConstructorsConstructorDescriptionChunkCoordinatorBuilder
(@NonNull ChunkCoordinatorFactory chunkCoordinatorFactory) -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Create a newChunkCoordinator
instance based on the values in the Builder instance.forceSync
(boolean forceSync) Set whether the chunks coordinator should be forced to be synchronous.Set the worldunloadAfter
(boolean unloadAfter) Set whether the chunks should be allow to unload after being accessed.withChunk
(@NonNull BlockVector2 chunkLocation) Add a chunk to be accessedwithChunks
(@NonNull Collection<BlockVector2> chunkLocations) Add a Collection of chunks to be accessedwithConsumer
(@NonNull Consumer<BlockVector2> chunkConsumer) Set the consumer to be used when a chunk is loadedwithFinalAction
(@Nullable Runnable whenDone) Set the Runnable to run when all chunks have been accessedwithInitialBatchSize
(int initialBatchSize) Set the initial batch size to be used for loading chunkswithMaxIterationTime
(long maxIterationTime) Set the max time taken while iterating over and accessing loaded chunkswithProgressSubscriber
(ProgressSubscriber progressSubscriber) withProgressSubscribers
(Collection<ProgressSubscriber> progressSubscribers) withRegion
(@NonNull Location pos1, @NonNull Location pos2) Add chunks within a region to be accessedwithThrowableConsumer
(@NonNull Consumer<Throwable> throwableConsumer) Set the consumer to be used to handleThrowable
s
-
Constructor Details
-
ChunkCoordinatorBuilder
-
-
Method Details
-
inWorld
Set the world- Parameters:
world
- world- Returns:
- this ChunkCoordinatorBuilder instance
-
withChunk
Add a chunk to be accessed- Parameters:
chunkLocation
- BlockVector2 of chunk to add- Returns:
- this ChunkCoordinatorBuilder instance
-
withChunks
public @NonNull ChunkCoordinatorBuilder withChunks(@NonNull Collection<BlockVector2> chunkLocations) Add a Collection of chunks to be accessed- Parameters:
chunkLocations
- Collection of BlockVector2 to add- Returns:
- this ChunkCoordinatorBuilder instance
-
withRegion
Add chunks within a region to be accessed- Parameters:
pos1
- minimum region locationpos2
- maximum region location- Returns:
- this ChunkCoordinatorBuilder instance
-
withConsumer
Set the consumer to be used when a chunk is loaded- Parameters:
chunkConsumer
- Consumer to be used by the ChunkCoordinator- Returns:
- this ChunkCoordinatorBuilder instance
-
withFinalAction
Set the Runnable to run when all chunks have been accessed- Parameters:
whenDone
- task to run when all chunks are accessed- Returns:
- this ChunkCoordinatorBuilder instance
-
withMaxIterationTime
Set the max time taken while iterating over and accessing loaded chunks- Parameters:
maxIterationTime
- max iteration time- Returns:
- this ChunkCoordinatorBuilder instance
-
withInitialBatchSize
Set the initial batch size to be used for loading chunks- Parameters:
initialBatchSize
- initial batch size- Returns:
- this ChunkCoordinatorBuilder instance
-
withThrowableConsumer
public @NonNull ChunkCoordinatorBuilder withThrowableConsumer(@NonNull Consumer<Throwable> throwableConsumer) Set the consumer to be used to handleThrowable
s- Parameters:
throwableConsumer
- consumer to hanble throwables- Returns:
- this ChunkCoordinatorBuilder instance
-
unloadAfter
Set whether the chunks should be allow to unload after being accessed. This should only be used where the chunks are read from and then written to from a separate queue where they're consequently unloaded.- Parameters:
unloadAfter
- if to unload chuns afterwards- Returns:
- this ChunkCoordinatorBuilder instance
-
forceSync
Set whether the chunks coordinator should be forced to be synchronous. This is not necessarily synchronous to the server, and simply effectively makesChunkCoordinator.start()
()} a blocking operation.- Parameters:
forceSync
- force sync or not- Since:
- 6.9.0
-
withProgressSubscriber
public @NonNull ChunkCoordinatorBuilder withProgressSubscriber(ProgressSubscriber progressSubscriber) -
withProgressSubscribers
public @NonNull ChunkCoordinatorBuilder withProgressSubscribers(Collection<ProgressSubscriber> progressSubscribers) -
build
Create a newChunkCoordinator
instance based on the values in the Builder instance.- Returns:
- a new ChunkCoordinator
-