MCCoroutine is a library, which adds extensive support for Kotlin Coroutines for Minecraft Server environments.
OTHER License
branch | status | version | download |
---|---|---|---|
master | Download latest release | ||
development | Download snapshots |
MCCoroutine is a library, which adds extensive support for Kotlin Coroutines for Minecraft Server environments.
Plugins for game servers and proxy servers often need to perform asynchronous operations (e.g. accessing databases) to be scalable for a large amount of players. MCCoroutine brings the full power of Kotlin Coroutines to them by extending the existing APIs with suspendable commands, events and schedules.
Supported Game Servers:
Supported Proxies:
Examples:
// Allows to prepend suspend to any listener function.
class PlayerConnectListener : Listener {
@EventHandler
suspend fun onPlayerJoinEvent(playerJoinEvent: PlayerJoinEvent) {
}
}
// Adds a new interface for suspendable command executors.
class AdminCommandExecutor: SuspendingCommandExecutor {
override suspend fun onCommand(sender: CommandSender,command: Command,label: String,args: Array<out String>): Boolean {
return false
}
}
// Adds a new extension function to switch into a suspendable plugin coroutine.
fun bar() {
plugin.launch {
delay(1000)
bob()
}
}
private suspend fun bob() {
}
The source code is licensed under the MIT license.