MCCoroutine [API|1.7-1.17] 1.4.0

MCCoroutine is library which adds extensive support for Kotlin Coroutines on Minecraft Servers.

  1. Shynixn
    Tested Minecraft Versions:
    • 1.7
    • 1.8
    • 1.9
    • 1.10
    • 1.11
    • 1.12
    • 1.13
    • 1.14
    • 1.15
    • 1.16
    • 1.17
    Source Code:
    https://github.com/Shynixn/MCCoroutine
    What's MCCoroutine?

    MCCoroutine is an extension to bukkit and sponge server implementations (Spigot, Paper, SpongeVanilla, SpongeForge etc.) to use Kotlin Coroutines (async,await) for all common operations.

    Getting Started
    Features
    • Full implementation of Kotlin Coroutines (async/await)
    • Extension functions for already established functions
    • Connection to events, commands, schedulers
    • Coroutine LifeCycle scope for plugins (supports plugin reloading)
    • No NMS
    • Support for Minecraft 1.7 - Latest
    • Support for Java 8
    Code Examples

    Allows to prepend suspend to any listener function.

    Code (Java):
    @EventHandler
    suspend fun onPlayerJoinEvent(playerJoinEvent: PlayerJoinEvent) {
           val player = playerJoinEvent.player
           val playerData = database.getDataFromPlayer(player)
           playerData.name = player.name
           playerData.lastJoinDate = Date()
           database.saveData(player, playerData)
    }
    Allows to prepend suspend to any command executor.

    Code (Java):
    override suspend fun onCommand(
            sender: CommandSender,
            command: Command,
            label: String,
            args: Array<out String>
        ): Boolean {
            if (sender !is Player) {
                return false
            }

            if (args.size == 2 && args[0].equals("rename", true)) {
                val name = args[1]
                val playerData = database.getDataFromPlayer(sender)
                playerData.name = name
                database.saveData(sender, playerData)
                return true
            }

            return false
    }