@ -13,14 +13,15 @@ abstract class GenerationTask(plugin: Chunkmaster, centerChunk: Chunk, startChun
abstract val stopAfter : Int
abstract val stopAfter : Int
abstract val world : World
abstract val world : World
abstract val count : Int
abstract val count : Int
abstract val lastChunk : Chunk
abstract val endReached : Boolean
abstract val endReached : Boolean
protected val spiral : Spiral =
protected val spiral : Spiral =
Spiral ( Pair ( centerChunk . x , centerChunk . z ) , Pair ( startChunk . x , startChunk . z ) )
Spiral ( Pair ( centerChunk . x , centerChunk . z ) , Pair ( startChunk . x , startChunk . z ) )
protected val loadedChunks : HashSet < Chunk > = HashSet ( )
protected val loadedChunks : HashSet < Chunk > = HashSet ( )
protected var lastChunkCoords = ChunkCoordinates ( startChunk . x , startChunk . z )
protected val chunkSkips = plugin . config . getInt ( " generation.chunks-skips-per-step " )
protected val chunkSkips = plugin . config . getInt ( " generation.chunks-skips-per-step " )
protected val msptThreshold = plugin . config . getLong ( " generation.mspt-pause-threshold " )
protected val msptThreshold = plugin . config . getLong ( " generation.mspt-pause-threshold " )
protected val maxLoadedChunks = plugin . config . getInt ( " generation.max-loaded-chunks " )
abstract override fun run ( )
abstract override fun run ( )
abstract fun cancel ( )
abstract fun cancel ( )
@ -30,13 +31,21 @@ abstract class GenerationTask(plugin: Chunkmaster, centerChunk: Chunk, startChun
val nextChunkCoords = spiral . next ( )
val nextChunkCoords = spiral . next ( )
return ChunkCoordinates ( nextChunkCoords . first , nextChunkCoords . second )
return ChunkCoordinates ( nextChunkCoords . first , nextChunkCoords . second )
}
}
var lastChunk : Chunk = startChunk
get ( ) {
return world . getChunkAt ( lastChunkCoords . x , lastChunkCoords . z )
}
private set
val nextChunk : Chunk
val nextChunk : Chunk
get ( ) {
get ( ) {
val next = nextChunkCoordinates
val next = nextChunkCoordinates
return world . getChunkAt ( next . x , next . z )
return world . getChunkAt ( next . x , next . z )
}
}
/ * *
* Checks if the World border or the maximum chunk setting for the task is reached .
* /
protected fun borderReached ( ) : Boolean {
protected fun borderReached ( ) : Boolean {
return ! world . worldBorder . isInside ( lastChunk . getBlock ( 8 , 0 , 8 ) . location ) || ( stopAfter in 1. . count )
return ! world . worldBorder . isInside ( lastChunk Coords. getCenterLocation ( world ) ) || ( stopAfter in 1. . count )
}
}
}
}