TaskSequenceBuilder

class TaskSequenceBuilder(val plugin: Plugin, val player: Player? = null)

TaskSequenceBuilder provides a DSL for creating a sequence of tasks with delays.

Constructors

Link copied to clipboard
constructor(plugin: Plugin, player: Player? = null)

Properties

Link copied to clipboard
val player: Player?

The player associated with this sequence, if any.

Link copied to clipboard
val plugin: Plugin

The plugin associated with this sequence.

Functions

Link copied to clipboard
suspend fun <T> async(block: suspend CoroutineScope.() -> T): T

Runs the block asynchronously.

Link copied to clipboard
fun packet(action: PacketBuilder.() -> Unit)

Performs an action using the Packet DSL for the player. If the player is not specified, this does nothing.

Link copied to clipboard
suspend fun repeat(times: Int, block: suspend TaskSequenceBuilder.(Int) -> Unit)

Repeats the block times.

Link copied to clipboard
suspend fun repeatEvery(times: Int, delay: Ticks, block: suspend TaskSequenceBuilder.(Int) -> Unit)

Repeats the block times with a delay between each iteration.

Link copied to clipboard
suspend fun repeatUntil(condition: () -> Boolean, block: suspend TaskSequenceBuilder.() -> Unit)

Repeats the block until condition is true.

Link copied to clipboard
suspend fun repeatWhile(condition: () -> Boolean, block: suspend TaskSequenceBuilder.() -> Unit)

Repeats the block while condition is true.

Link copied to clipboard
suspend fun runIf(condition: () -> Boolean, block: suspend TaskSequenceBuilder.() -> Unit)

Runs the block if the condition is true.

Link copied to clipboard
suspend fun runUnless(condition: () -> Boolean, block: suspend TaskSequenceBuilder.() -> Unit)

Runs the block if the condition is false.

Link copied to clipboard
fun sendActionBar(message: Component)

Sends an action bar message to the player if they are online.

Link copied to clipboard
fun sendMessage(message: Component)

Sends a message to the player if they are online.

Link copied to clipboard
suspend fun <T> sync(block: suspend CoroutineScope.() -> T): T

Runs the block on the Bukkit main thread.

Link copied to clipboard
suspend fun <T> timeout(ticks: Ticks, block: suspend TaskSequenceBuilder.() -> T): T?

Runs the block with a timeout. If the block takes longer than ticks, it will be cancelled.

Link copied to clipboard
suspend fun wait(ticks: Ticks)

Suspends the sequence for the specified number of ticks.

suspend fun wait(duration: Duration)

Suspends the sequence for the specified duration.

suspend fun wait(ticks: Int)
suspend fun wait(ticks: Long)

Suspends the sequence for the specified number of ticks.

Link copied to clipboard
suspend fun waitUntil(checkInterval: Ticks = 1.ticks, condition: () -> Boolean)

Suspends the sequence until the condition is met.

Link copied to clipboard
suspend fun yield()

Suspends the sequence for 1 tick.