Package com.github.shynixn.mccoroutine.sponge

Types

CoroutineSession
Link copied to clipboard
interface CoroutineSession

Facade of a coroutine session of a single plugin.

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
MCCoroutineExceptionEvent
Link copied to clipboard
class MCCoroutineExceptionEvent(plugin: <ERROR CLASS>, exception: Throwable)

A sponge 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.

SuspendingCommandElement
Link copied to clipboard
abstract class SuspendingCommandElement(pluginContainer: <ERROR CLASS>, text: <ERROR CLASS>)
SuspendingCommandExecutor
Link copied to clipboard
interface SuspendingCommandExecutor

Interface containing the method directing how a certain command will be executed.

SuspendingPluginContainer
Link copied to clipboard
class SuspendingPluginContainer

When injecting this class into one instance of your plugin, the instance of your plugin automatically becomes a suspending listener, so you can append suspend to any of your startup methods.

Functions

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.

postSuspending
Link copied to clipboard
fun <ERROR CLASS>.postSuspending(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>.postSuspending(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.

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

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

suspendingExecutor
Link copied to clipboard
fun <ERROR CLASS>.suspendingExecutor(plugin: <ERROR CLASS>, suspendingCommandExecutor: SuspendingCommandExecutor): <ERROR CLASS>

Registers an command executor 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.

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 SpongeScheduler 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.