Package com.plotsquared.core.queue
Class ChunkCoordinatorBuilder
java.lang.Object
com.plotsquared.core.queue.ChunkCoordinatorBuilder
Builds a
ChunkCoordinator
instance-
Constructor Summary
ConstructorDescriptionChunkCoordinatorBuilder(@NonNull ChunkCoordinatorFactory chunkCoordinatorFactory)
-
Method Summary
Modifier and TypeMethodDescription@NonNull ChunkCoordinator
build()
Create a newChunkCoordinator
instance based on the values in the Builder instance.@NonNull ChunkCoordinatorBuilder
inWorld(@NonNull com.sk89q.worldedit.world.World world)
Set the world@NonNull ChunkCoordinatorBuilder
unloadAfter(boolean unloadAfter)
Set whether the chunks should be allow to unload after being accessed.@NonNull ChunkCoordinatorBuilder
withChunk(@NonNull com.sk89q.worldedit.math.BlockVector2 chunkLocation)
Add a chunk to be accessed@NonNull ChunkCoordinatorBuilder
withChunks(@NonNull Collection<com.sk89q.worldedit.math.BlockVector2> chunkLocations)
Add a Collection of chunks to be accessed@NonNull ChunkCoordinatorBuilder
withConsumer(@NonNull Consumer<com.sk89q.worldedit.math.BlockVector2> chunkConsumer)
Set the consumer to be used when a chunk is loaded@NonNull ChunkCoordinatorBuilder
withFinalAction(@Nullable Runnable whenDone)
Set the Runnable to run when all chunks have been accessed@NonNull ChunkCoordinatorBuilder
withInitialBatchSize(int initialBatchSize)
Set the initial batch size to be used for loading chunks@NonNull ChunkCoordinatorBuilder
withMaxIterationTime(long maxIterationTime)
Set the max time taken while iterating over and accessing loaded chunks@NonNull ChunkCoordinatorBuilder
withProgressSubscriber(ProgressSubscriber progressSubscriber)
@NonNull ChunkCoordinatorBuilder
withProgressSubscribers(Collection<ProgressSubscriber> progressSubscribers)
@NonNull ChunkCoordinatorBuilder
withRegion(@NonNull Location pos1, @NonNull Location pos2)
Add chunks within a region to be accessed@NonNull ChunkCoordinatorBuilder
withThrowableConsumer(@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
public @NonNull ChunkCoordinatorBuilder withChunk(@NonNull com.sk89q.worldedit.math.BlockVector2 chunkLocation)Add a chunk to be accessed- Parameters:
chunkLocation
- BlockVector2 of chunk to add- Returns:
- this ChunkCoordinatorBuilder instance
-
withChunks
public @NonNull ChunkCoordinatorBuilder withChunks(@NonNull Collection<com.sk89q.worldedit.math.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
public @NonNull ChunkCoordinatorBuilder withConsumer(@NonNull Consumer<com.sk89q.worldedit.math.BlockVector2> chunkConsumer)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
-
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
-