PluginCoroutineScope

class PluginCoroutineScope(plugin: JavaPlugin, logger: Logger)(source)

Provides a coroutine scope tied to the plugin lifecycle.

This scope:

  • Uses Dispatchers.Default for background CPU-bound work

  • Uses SupervisorJob to prevent child failures from canceling the entire scope

  • Is properly cancelled when the plugin disables

Usage:

pluginScope.launch {
val result = withTimeout(5000) {
someAsyncOperation()
}
// Handle result...
}

Constructors

Link copied to clipboard
constructor(plugin: JavaPlugin, logger: Logger)

Properties

Link copied to clipboard
val scope: CoroutineScope

Functions

Link copied to clipboard
fun cancel()

Cancels all coroutines in this scope. Should be called during plugin disable.