Package com.github.shynixn.mccoroutine.bukkit

Types

CoroutineSession
Link copied to clipboard
interface CoroutineSession

Facade of a coroutine session of a single plugin.

CoroutineTimings
Link copied to clipboard
abstract class CoroutineTimings : AbstractCoroutineContextElement, Runnable

The spigot timings require a reference to the runnable to display the name of timings correctly. Now, Kotlin Coroutines does not allow to directly pass a runnable object, because a single coroutine may consist out of multiple runnables. This class is a workaround coroutine context element, which can be passed along the minecraftDispatcher to display a valid name for the coroutine.

EventExecutionType
Link copied to clipboard
enum EventExecutionType : Enum<EventExecutionType>

The mode how suspendable events are executed if dispatched manually.

MCCoroutine
Link copied to clipboard
interface MCCoroutine

Hidden internal MCCoroutine interface.

MCCoroutineConfiguration
Link copied to clipboard
interface MCCoroutineConfiguration

Additional configurations for MCCoroutine and communication.

MCCoroutineExceptionEvent
Link copied to clipboard
class MCCoroutineExceptionEvent(plugin: <ERROR CLASS>, exception: Throwable)

A Bukkit event which is called when an exception is raised in one of the coroutines managed by MCCoroutine. Cancelling this exception causes the error to not get logged and offers to possibility for custom logging.

ShutdownStrategy
Link copied to clipboard
enum ShutdownStrategy : Enum<ShutdownStrategy>

See https://shynixn.github.io/MCCoroutine/wiki/site/plugindisable for more details.

SuspendingCommandExecutor
Link copied to clipboard
interface SuspendingCommandExecutor

Represents a class which contains a single method for executing commands

SuspendingJavaPlugin
Link copied to clipboard
open class SuspendingJavaPlugin : SuspendingPlugin

Extension to the JavaPlugin for suspendable lifecycle functions.

SuspendingPlugin
Link copied to clipboard
interface SuspendingPlugin

Extension to the plugin interface for suspendable lifecycle functions.

SuspendingTabCompleter
Link copied to clipboard
interface SuspendingTabCompleter

Represents a suspending class which can suggest tab completions for commands.

Functions

callSuspendingEvent
Link copied to clipboard
fun <ERROR CLASS>.callSuspendingEvent(event: <ERROR CLASS>, plugin: <ERROR CLASS>): Collection<<ERROR CLASS>>

Calls an event with the given details. If there are multiple suspend event receivers, each receiver is executed concurrently. Allows to await the completion of suspending event listeners.

fun <ERROR CLASS>.callSuspendingEvent(event: <ERROR CLASS>, plugin: <ERROR CLASS>, eventExecutionType: EventExecutionType): Collection<<ERROR CLASS>>

Calls an event with the given details. Allows to await the completion of suspending event listeners.

launch
Link copied to clipboard
fun <ERROR CLASS>.launch(context: CoroutineContext = minecraftDispatcher, start: <ERROR CLASS> = CoroutineStart.DEFAULT, block: suspend <ERROR CLASS>.() -> Unit): <ERROR CLASS>

Launches a new coroutine on the minecraft main thread without blocking the current thread and returns a reference to the coroutine as a Job. The coroutine is cancelled when the resulting job is Job.cancel.

registerSuspendingEvents
Link copied to clipboard
fun <ERROR CLASS>.registerSuspendingEvents(listener: <ERROR CLASS>, plugin: <ERROR CLASS>)

Registers an event listener with suspending functions. Does exactly the same thing as PluginManager.registerEvents but makes suspend functions possible. Example:

setSuspendingExecutor
Link copied to clipboard
fun <ERROR CLASS>.setSuspendingExecutor(suspendingCommandExecutor: SuspendingCommandExecutor)
fun <ERROR CLASS>.setSuspendingExecutor(context: CoroutineContext, suspendingCommandExecutor: SuspendingCommandExecutor)

Registers a command executor with suspending function. Does exactly the same as PluginCommand.setExecutor.

setSuspendingTabCompleter
Link copied to clipboard
fun <ERROR CLASS>.setSuspendingTabCompleter(suspendingTabCompleter: SuspendingTabCompleter)
fun <ERROR CLASS>.setSuspendingTabCompleter(context: CoroutineContext, suspendingTabCompleter: SuspendingTabCompleter)

Registers a tab completer with suspending function. Does exactly the same as PluginCommand.setExecutor.

Properties

asyncDispatcher
Link copied to clipboard
val <ERROR CLASS>.asyncDispatcher: CoroutineContext

Gets the plugin async dispatcher.

mcCoroutineConfiguration
Link copied to clipboard
val <ERROR CLASS>.mcCoroutineConfiguration: MCCoroutineConfiguration

Gets the configuration instance of MCCoroutine.

minecraftDispatcher
Link copied to clipboard
val <ERROR CLASS>.minecraftDispatcher: CoroutineContext

Gets the plugin minecraft dispatcher.

scope
Link copied to clipboard
val <ERROR CLASS>.scope: <ERROR CLASS>

Gets the plugin coroutine scope.

ticks
Link copied to clipboard
val Int.ticks: Long

Converts the number to ticks for being used together with delay(..). E.g. delay(1.ticks). Minecraft ticks 20 times per second, which means a tick appears every 50 milliseconds. However, delay() does not directly work with the BukkitScheduler and needs millisecond manipulation to work as expected. Therefore, 1 tick does not equal 50 milliseconds when using this method standalone and only sums up to 50 milliseconds if you use it together with delay.