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 TypeMethodDescription@NonNull ChunkCoordinatorbuild()Create a newChunkCoordinatorinstance based on the values in the Builder instance.@NonNull ChunkCoordinatorBuilderforceSync(boolean forceSync) Set whether the chunks coordinator should be forced to be synchronous.@NonNull ChunkCoordinatorBuilderSet the world@NonNull ChunkCoordinatorBuilderunloadAfter(boolean unloadAfter) Set whether the chunks should be allow to unload after being accessed.@NonNull ChunkCoordinatorBuilderwithChunk(@NonNull BlockVector2 chunkLocation) Add a chunk to be accessed@NonNull ChunkCoordinatorBuilderwithChunks(@NonNull Collection<BlockVector2> chunkLocations) Add a Collection of chunks to be accessed@NonNull ChunkCoordinatorBuilderwithConsumer(@NonNull Consumer<BlockVector2> chunkConsumer) Set the consumer to be used when a chunk is loaded@NonNull ChunkCoordinatorBuilderwithFinalAction(@Nullable Runnable whenDone) Set the Runnable to run when all chunks have been accessed@NonNull ChunkCoordinatorBuilderwithInitialBatchSize(int initialBatchSize) Set the initial batch size to be used for loading chunks@NonNull ChunkCoordinatorBuilderwithMaxIterationTime(long maxIterationTime) Set the max time taken while iterating over and accessing loaded chunks@NonNull ChunkCoordinatorBuilderwithProgressSubscriber(ProgressSubscriber progressSubscriber) @NonNull ChunkCoordinatorBuilderwithProgressSubscribers(Collection<ProgressSubscriber> progressSubscribers) @NonNull ChunkCoordinatorBuilderwithRegion(@NonNull Location pos1, @NonNull Location pos2) Add chunks within a region to be accessed@NonNull ChunkCoordinatorBuilderwithThrowableConsumer(@NonNull Consumer<Throwable> throwableConsumer) Set the consumer to be used to handleThrowables
-
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 handleThrowables- 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 chunks 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 newChunkCoordinatorinstance based on the values in the Builder instance.- Returns:
- a new ChunkCoordinator
-