diff --git a/build.gradle b/build.gradle index c7b238b3..a102011f 100644 --- a/build.gradle +++ b/build.gradle @@ -43,7 +43,7 @@ tasks.register("printVersion") { subprojects { group 'com.github.shynixn.mccoroutine' - version '2.11.0' + version '2.12.0' sourceCompatibility = 1.8 diff --git a/docs/wiki/docs/installation.md b/docs/wiki/docs/installation.md index a4aa9387..5b1556f8 100644 --- a/docs/wiki/docs/installation.md +++ b/docs/wiki/docs/installation.md @@ -8,8 +8,8 @@ In order to use the MCCoroutine Kotlin API, you need to include the following li ```groovy dependencies { - implementation("com.github.shynixn.mccoroutine:mccoroutine-bukkit-api:2.11.0") - implementation("com.github.shynixn.mccoroutine:mccoroutine-bukkit-core:2.11.0") + implementation("com.github.shynixn.mccoroutine:mccoroutine-bukkit-api:2.12.0") + implementation("com.github.shynixn.mccoroutine:mccoroutine-bukkit-core:2.12.0") } ``` @@ -17,8 +17,8 @@ In order to use the MCCoroutine Kotlin API, you need to include the following li ```groovy dependencies { - implementation("com.github.shynixn.mccoroutine:mccoroutine-bungeecord-api:2.11.0") - implementation("com.github.shynixn.mccoroutine:mccoroutine-bungeecord-core:2.11.0") + implementation("com.github.shynixn.mccoroutine:mccoroutine-bungeecord-api:2.12.0") + implementation("com.github.shynixn.mccoroutine:mccoroutine-bungeecord-core:2.12.0") } ``` @@ -26,8 +26,8 @@ In order to use the MCCoroutine Kotlin API, you need to include the following li ```groovy dependencies { - implementation("com.github.shynixn.mccoroutine:mccoroutine-sponge-api:2.11.0") - implementation("com.github.shynixn.mccoroutine:mccoroutine-sponge-core:2.11.0") + implementation("com.github.shynixn.mccoroutine:mccoroutine-sponge-api:2.12.0") + implementation("com.github.shynixn.mccoroutine:mccoroutine-sponge-core:2.12.0") } ``` @@ -35,8 +35,8 @@ In order to use the MCCoroutine Kotlin API, you need to include the following li ```groovy dependencies { - implementation("com.github.shynixn.mccoroutine:mccoroutine-velocity-api:2.11.0") - implementation("com.github.shynixn.mccoroutine:mccoroutine-velocity-core:2.11.0") + implementation("com.github.shynixn.mccoroutine:mccoroutine-velocity-api:2.12.0") + implementation("com.github.shynixn.mccoroutine:mccoroutine-velocity-core:2.12.0") } ``` @@ -44,8 +44,8 @@ In order to use the MCCoroutine Kotlin API, you need to include the following li ```groovy dependencies { - implementation("com.github.shynixn.mccoroutine:mccoroutine-minestom-api:2.11.0") - implementation("com.github.shynixn.mccoroutine:mccoroutine-minestom-core:2.11.0") + implementation("com.github.shynixn.mccoroutine:mccoroutine-minestom-api:2.12.0") + implementation("com.github.shynixn.mccoroutine:mccoroutine-minestom-core:2.12.0") } ``` @@ -53,8 +53,8 @@ In order to use the MCCoroutine Kotlin API, you need to include the following li ```groovy dependencies { - implementation("com.github.shynixn.mccoroutine:mccoroutine-fabric-api:2.11.0") - implementation("com.github.shynixn.mccoroutine:mccoroutine-fabric-core:2.11.0") + implementation("com.github.shynixn.mccoroutine:mccoroutine-fabric-api:2.12.0") + implementation("com.github.shynixn.mccoroutine:mccoroutine-fabric-core:2.12.0") } ``` @@ -78,8 +78,8 @@ dependencies { **plugin.yml** ```yaml libraries: - - com.github.shynixn.mccoroutine:mccoroutine-bukkit-api:2.11.0 - - com.github.shynixn.mccoroutine:mccoroutine-bukkit-core:2.11.0 + - com.github.shynixn.mccoroutine:mccoroutine-bukkit-api:2.12.0 + - com.github.shynixn.mccoroutine:mccoroutine-bukkit-core:2.12.0 ``` === "Other Server" diff --git a/docs/wiki/docs/unittests.md b/docs/wiki/docs/unittests.md index 34502535..1a088b74 100644 --- a/docs/wiki/docs/unittests.md +++ b/docs/wiki/docs/unittests.md @@ -18,7 +18,7 @@ feedback to the real environment. ```kotlin dependencies { - testImplementation("com.github.shynixn.mccoroutine:mccoroutine-bukkit-test:2.11.0") + testImplementation("com.github.shynixn.mccoroutine:mccoroutine-bukkit-test:2.12.0") } ``` diff --git a/mccoroutine-bukkit-core/src/main/java/com/github/shynixn/mccoroutine/bukkit/service/EventServiceImpl.kt b/mccoroutine-bukkit-core/src/main/java/com/github/shynixn/mccoroutine/bukkit/service/EventServiceImpl.kt index 395247d8..05db45b1 100644 --- a/mccoroutine-bukkit-core/src/main/java/com/github/shynixn/mccoroutine/bukkit/service/EventServiceImpl.kt +++ b/mccoroutine-bukkit-core/src/main/java/com/github/shynixn/mccoroutine/bukkit/service/EventServiceImpl.kt @@ -188,6 +188,7 @@ internal class EventServiceImpl(private val plugin: Plugin) { private val method: Method, private val plugin: Plugin ) : EventExecutor { + var isSuspendMethod: Boolean? = null fun executeSuspend(listener: Listener, event: Event): Job { return executeEvent(listener, event) } @@ -210,11 +211,19 @@ internal class EventServiceImpl(private val plugin: Plugin) { // We want to start it on the same thread as the calling thread -> unDispatched. // However, after a possible suspension we either end up on the asyncDispatcher or minecraft Dispatcher. return plugin.launch(dispatcher, CoroutineStart.UNDISPATCHED) { - try { - // Try as suspension function. + if (isSuspendMethod == null) { + try { + // Try as suspension function. + method.invokeSuspend(listener, event) + isSuspendMethod = true + } catch (e: IllegalArgumentException) { + // Try as ordinary function. + method.invoke(listener, event) + isSuspendMethod = false + } + } else if (isSuspendMethod!!) { method.invokeSuspend(listener, event) - } catch (e: IllegalArgumentException) { - // Try as ordinary function. + } else { method.invoke(listener, event) } } diff --git a/mccoroutine-bukkit-sample/src/main/resources/plugin.yml b/mccoroutine-bukkit-sample/src/main/resources/plugin.yml index 41646781..f730982b 100644 --- a/mccoroutine-bukkit-sample/src/main/resources/plugin.yml +++ b/mccoroutine-bukkit-sample/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ name: MCCoroutine-Sample -version: 2.11.0 +version: 2.12.0 author: Shynixn main: com.github.shynixn.mccoroutine.bukkit.sample.MCCoroutineSamplePlugin commands: diff --git a/mccoroutine-bungeecord-sample/src/main/resources/plugin.yml b/mccoroutine-bungeecord-sample/src/main/resources/plugin.yml index 0ef873a9..4f1ce36a 100644 --- a/mccoroutine-bungeecord-sample/src/main/resources/plugin.yml +++ b/mccoroutine-bungeecord-sample/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ name: MCCoroutine-Sample -version: 2.11.0 +version: 2.12.0 author: Shynixn main: com.github.shynixn.mccoroutine.bungeecord.sample.MCCoroutineSamplePlugin commands: diff --git a/mccoroutine-fabric-sample/build.gradle.kts b/mccoroutine-fabric-sample/build.gradle.kts index b67aa845..ea4d40e7 100644 --- a/mccoroutine-fabric-sample/build.gradle.kts +++ b/mccoroutine-fabric-sample/build.gradle.kts @@ -9,8 +9,8 @@ repositories { mavenLocal() } dependencies { - implementation("com.github.shynixn.mccoroutine:mccoroutine-fabric-api:2.11.0") - implementation("com.github.shynixn.mccoroutine:mccoroutine-fabric-core:2.11.0") + implementation("com.github.shynixn.mccoroutine:mccoroutine-fabric-api:2.12.0") + implementation("com.github.shynixn.mccoroutine:mccoroutine-fabric-core:2.12.0") minecraft("com.mojang", "minecraft", project.extra["minecraft_version"] as String) mappings("net.fabricmc", "yarn", project.extra["yarn_mappings"] as String, null, "v2") diff --git a/mccoroutine-minestom-sample/src/main/resources/extension.json b/mccoroutine-minestom-sample/src/main/resources/extension.json index a257ea48..57d9d982 100644 --- a/mccoroutine-minestom-sample/src/main/resources/extension.json +++ b/mccoroutine-minestom-sample/src/main/resources/extension.json @@ -1,5 +1,5 @@ { "entrypoint": "com.github.shynixn.mccoroutine.minestom.sample.extension.MCCoroutineSampleExtension", "name": "MCCoroutineSampleExtension", - "version": "2.11.0" + "version": "2.12.0" } diff --git a/mccoroutine-sponge-sample/src/main/resources/mcmod.info b/mccoroutine-sponge-sample/src/main/resources/mcmod.info index 46385ec1..a81381ca 100644 --- a/mccoroutine-sponge-sample/src/main/resources/mcmod.info +++ b/mccoroutine-sponge-sample/src/main/resources/mcmod.info @@ -1,7 +1,7 @@ [{ "modid": "mccoroutinesample", "name": "MCCoroutineSample", - "version": "2.11.0", + "version": "2.12.0", "description": "MCCoroutineSample is sample plugin to use MCCoroutine in Sponge.", "authorList": [ "Shynixn"