From c22ba27962f29b8a110dd95a673a9d5fbc48ced5 Mon Sep 17 00:00:00 2001 From: geeyoueye <40792778+geeyoueye@users.noreply.github.com> Date: Mon, 11 Mar 2024 12:28:02 +0200 Subject: [PATCH 1/3] Fixed Folia detection. --- .../shynixn/mccoroutine/folia/impl/CoroutineSessionImpl.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mccoroutine-folia-core/src/main/java/com/github/shynixn/mccoroutine/folia/impl/CoroutineSessionImpl.kt b/mccoroutine-folia-core/src/main/java/com/github/shynixn/mccoroutine/folia/impl/CoroutineSessionImpl.kt index 49f94ce..2820836 100644 --- a/mccoroutine-folia-core/src/main/java/com/github/shynixn/mccoroutine/folia/impl/CoroutineSessionImpl.kt +++ b/mccoroutine-folia-core/src/main/java/com/github/shynixn/mccoroutine/folia/impl/CoroutineSessionImpl.kt @@ -30,7 +30,7 @@ internal class CoroutineSessionImpl( */ override val isFoliaLoaded: Boolean by lazy { try { - Class.forName("io.papermc.paper.threadedregions.scheduler.EntityScheduler") + Class.forName("io.papermc.paper.threadedregions.RegionizedServer") true } catch (e: ClassNotFoundException) { false From ec8101dc0686a782375174544769ba3950962b17 Mon Sep 17 00:00:00 2001 From: shynixn Date: Tue, 12 Mar 2024 18:51:49 +0100 Subject: [PATCH 2/3] Removed minestome tests. --- .../test/java/helper/MockedMinestomServer.kt | 41 ------- .../integrationtest/MinestomCommandTest.kt | 62 ----------- .../java/integrationtest/MinestomEventTest.kt | 100 ------------------ .../integrationtest/MinestomExceptionTest.kt | 58 ---------- 4 files changed, 261 deletions(-) delete mode 100644 mccoroutine-minestom-core/src/test/java/helper/MockedMinestomServer.kt delete mode 100644 mccoroutine-minestom-core/src/test/java/integrationtest/MinestomCommandTest.kt delete mode 100644 mccoroutine-minestom-core/src/test/java/integrationtest/MinestomEventTest.kt delete mode 100644 mccoroutine-minestom-core/src/test/java/integrationtest/MinestomExceptionTest.kt diff --git a/mccoroutine-minestom-core/src/test/java/helper/MockedMinestomServer.kt b/mccoroutine-minestom-core/src/test/java/helper/MockedMinestomServer.kt deleted file mode 100644 index 8dfd84d..0000000 --- a/mccoroutine-minestom-core/src/test/java/helper/MockedMinestomServer.kt +++ /dev/null @@ -1,41 +0,0 @@ -package helper - -import net.minestom.server.MinecraftServer -import net.minestom.server.extensions.Extension -import org.slf4j.Logger - -class MockedMinestomServer { - fun boot(mlogger: Logger? = null): Extension { - val extension = MockedExtension(mlogger) - MinecraftServer.init() - Thread { - while (true) { - MinecraftServer.getSchedulerManager().processTick() - Thread.sleep(50) - } - }.start() - return extension - } - - class MockedExtension(private val logger: Logger?) : Extension() { - override fun initialize() { - } - - override fun terminate() { - } - - - /** - * Gets the logger for the extension - * - * @return The logger for the extension - */ - override fun getLogger(): Logger { - if (logger != null) { - return logger - } - - return super.getLogger() - } - } -} diff --git a/mccoroutine-minestom-core/src/test/java/integrationtest/MinestomCommandTest.kt b/mccoroutine-minestom-core/src/test/java/integrationtest/MinestomCommandTest.kt deleted file mode 100644 index 9385fec..0000000 --- a/mccoroutine-minestom-core/src/test/java/integrationtest/MinestomCommandTest.kt +++ /dev/null @@ -1,62 +0,0 @@ -package integrationtest - -import com.github.shynixn.mccoroutine.minestom.setSuspendingDefaultExecutor -import helper.MockedMinestomServer -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.runBlocking -import kotlinx.coroutines.withContext -import net.minestom.server.MinecraftServer -import net.minestom.server.command.builder.Command -import net.minestom.server.extensions.Extension -import org.junit.jupiter.api.Assertions -import org.junit.jupiter.api.Test - -class MinestomCommandTest { - /** - * Given - * a call of a simple suspending command - * When - * executeServerCommand is called from any context - * Then - * the command should be called on the correct threads. - */ - @Test - fun dispatchCommand_SimpleSuspendingCommandExecutor_ShouldCallOnCorrectThreads() { - val server = MockedMinestomServer() - val extension = server.boot() - var unitTestThreadId: Long - val testCommandExecutor = TestCommandExecutor(extension) - - runBlocking { - unitTestThreadId = Thread.currentThread().id - MinecraftServer.getCommandManager().register(testCommandExecutor) - MinecraftServer.getCommandManager().executeServerCommand("unittest") - } - - Thread.sleep(2000) - - Assertions.assertNotEquals(unitTestThreadId, testCommandExecutor.callThreadId) - Assertions.assertNotEquals(unitTestThreadId, testCommandExecutor.asyncThreadId) - Assertions.assertNotEquals(unitTestThreadId, testCommandExecutor.leaveThreadId) - } - - private class TestCommandExecutor(private val extension: Extension) : Command("unittest") { - var callThreadId = 0L - var asyncThreadId = 0L - var leaveThreadId = 0L - - init { - this.setSuspendingDefaultExecutor(extension) { sender, context -> - callThreadId = Thread.currentThread().id - - withContext(Dispatchers.IO) { - asyncThreadId = Thread.currentThread().id - Thread.sleep(50) - } - - leaveThreadId = Thread.currentThread().id - } - - } - } -} diff --git a/mccoroutine-minestom-core/src/test/java/integrationtest/MinestomEventTest.kt b/mccoroutine-minestom-core/src/test/java/integrationtest/MinestomEventTest.kt deleted file mode 100644 index 1301d7c..0000000 --- a/mccoroutine-minestom-core/src/test/java/integrationtest/MinestomEventTest.kt +++ /dev/null @@ -1,100 +0,0 @@ -package integrationtest - -import com.github.shynixn.mccoroutine.minestom.addSuspendingListener -import helper.MockedMinestomServer -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.runBlocking -import kotlinx.coroutines.withContext -import net.minestom.server.MinecraftServer -import net.minestom.server.entity.Player -import net.minestom.server.event.player.PlayerDisconnectEvent -import net.minestom.server.event.player.PlayerLoginEvent -import org.junit.jupiter.api.Assertions -import org.junit.jupiter.api.Test -import org.mockito.Mockito - -class MinestomEventTest { - /** - * Given a test listener - * When the test listener is register and join event is called - * then the join event should be called on the correct thread. - */ - @Test - fun registerSuspendListener_PlayerJoinEvent_ShouldCallEventWithCorrectThread() { - // Arrange - val server = MockedMinestomServer() - val extension = server.boot() - val testListener = TestListener() - var unitTestThreadId: Long - - // Act - runBlocking { - unitTestThreadId = Thread.currentThread().id - MinecraftServer.getGlobalEventHandler() - .addSuspendingListener(extension, PlayerLoginEvent::class.java) { e -> - testListener.onPlayerJoinEvent(e) - } - MinecraftServer.getGlobalEventHandler().call(PlayerLoginEvent(Mockito.mock(Player::class.java))) - } - - Thread.sleep(500) - - // Assert - Assertions.assertNotEquals(unitTestThreadId, testListener.joinEventCalledId) - Assertions.assertNotEquals(unitTestThreadId, testListener.asyncChatEventCalledId) - Assertions.assertNotEquals(unitTestThreadId, testListener.leaveThreadId) - Assertions.assertNotEquals(testListener.asyncChatEventCalledId, testListener.leaveThreadId) - } - - /** - * Given a test listener - * When the test listener is register and quit event is called - * then the quit event should be called on the correct thread. - */ - @Test - fun registerSuspendListener_PlayerQuitEvent_ShouldCallEventWithCorrectThread() { - // Arrange - val server = MockedMinestomServer() - val extension = server.boot() - val testListener = TestListener() - var unitTestThreadId: Long - - // Act - runBlocking { - unitTestThreadId = Thread.currentThread().id - MinecraftServer.getGlobalEventHandler() - .addSuspendingListener(extension, PlayerDisconnectEvent::class.java) { e -> - testListener.onPlayerQuitEvent(e) - } - MinecraftServer.getGlobalEventHandler().call(PlayerLoginEvent(Mockito.mock(Player::class.java))) - } - - Thread.sleep(500) - - // Assert - Assertions.assertNotEquals(unitTestThreadId, testListener.quitEventCalledId) - } - - class TestListener( - var joinEventCalledId: Long = 0L, - var quitEventCalledId: Long = 0L, - var asyncChatEventCalledId: Long = 0L, - var leaveThreadId: Long = 0L - ) { - - suspend fun onPlayerJoinEvent(event: PlayerLoginEvent) { - joinEventCalledId = Thread.currentThread().id - - withContext(Dispatchers.IO) { - Thread.sleep(100) - asyncChatEventCalledId = Thread.currentThread().id - } - - leaveThreadId = Thread.currentThread().id - } - - fun onPlayerQuitEvent(event: PlayerDisconnectEvent) { - quitEventCalledId = Thread.currentThread().id - } - } -} diff --git a/mccoroutine-minestom-core/src/test/java/integrationtest/MinestomExceptionTest.kt b/mccoroutine-minestom-core/src/test/java/integrationtest/MinestomExceptionTest.kt deleted file mode 100644 index 31b70c7..0000000 --- a/mccoroutine-minestom-core/src/test/java/integrationtest/MinestomExceptionTest.kt +++ /dev/null @@ -1,58 +0,0 @@ -package integrationtest - -import com.github.shynixn.mccoroutine.minestom.launch -import helper.MockedMinestomServer -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.runBlocking -import org.junit.jupiter.api.Assertions -import org.junit.jupiter.api.Test -import org.mockito.Mockito -import org.slf4j.Logger - -class MinestomExceptionTest { - /** - * Given - * multiple extension.launch() operations - * When - * 2 launches fail and one is successful - * The - * extension scope should not fail and the 2 failures be logged. - */ - @Test - fun extensionLaunch_MultipleFailingCoroutineScopes_ShouldBeCaughtInRootScopeAndKeepExtensionScopeRunning() { - // Arrange - val testServer = MockedMinestomServer() - val logger = Mockito.mock(Logger::class.java) - var logMessageCounter = 0 - Mockito.`when`( - logger.error(Mockito.anyString(), Mockito.any()) - ).thenAnswer { - logMessageCounter++ - } - val extension = testServer.boot(logger) - var actualThreadId = 0L - var ioThreadId: Long - - // Act - runBlocking(Dispatchers.IO) { - ioThreadId = Thread.currentThread().id - - extension.launch { - throw IllegalArgumentException("UnitTestFailure!") - } - - extension.launch { - throw IllegalArgumentException("Another UnitTestFailure!") - } - - extension.launch { - actualThreadId = Thread.currentThread().id - } - } - Thread.sleep(2000) - - // Assert - Assertions.assertNotEquals(ioThreadId, actualThreadId) - Assertions.assertEquals(2, logMessageCounter) - } -} From 04e9ce1f5734f3c800e329535c0c241a19832163 Mon Sep 17 00:00:00 2001 From: shynixn Date: Tue, 12 Mar 2024 18:56:33 +0100 Subject: [PATCH 3/3] Updated to release version. --- build.gradle | 2 +- docs/wiki/docs/installation.md | 36 +++++++++---------- docs/wiki/docs/unittests.md | 2 +- .../src/main/resources/plugin.yml | 2 +- .../src/main/resources/plugin.yml | 2 +- mccoroutine-fabric-sample/build.gradle.kts | 4 +-- .../src/main/resources/plugin.yml | 2 +- .../src/main/resources/extension.json | 2 +- .../src/main/resources/mcmod.info | 2 +- 9 files changed, 27 insertions(+), 27 deletions(-) diff --git a/build.gradle b/build.gradle index 47459ec..859c3c6 100644 --- a/build.gradle +++ b/build.gradle @@ -43,7 +43,7 @@ tasks.register("printVersion") { subprojects { group 'com.github.shynixn.mccoroutine' - version '2.14.0' + version '2.15.0' sourceCompatibility = 1.8 diff --git a/docs/wiki/docs/installation.md b/docs/wiki/docs/installation.md index 61e0b2e..ae40d2d 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.14.0") - implementation("com.github.shynixn.mccoroutine:mccoroutine-bukkit-core:2.14.0") + implementation("com.github.shynixn.mccoroutine:mccoroutine-bukkit-api:2.15.0") + implementation("com.github.shynixn.mccoroutine:mccoroutine-bukkit-core:2.15.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.14.0") - implementation("com.github.shynixn.mccoroutine:mccoroutine-bungeecord-core:2.14.0") + implementation("com.github.shynixn.mccoroutine:mccoroutine-bungeecord-api:2.15.0") + implementation("com.github.shynixn.mccoroutine:mccoroutine-bungeecord-core:2.15.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-fabric-api:2.14.0") - implementation("com.github.shynixn.mccoroutine:mccoroutine-fabric-core:2.14.0") + implementation("com.github.shynixn.mccoroutine:mccoroutine-fabric-api:2.15.0") + implementation("com.github.shynixn.mccoroutine:mccoroutine-fabric-core:2.15.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-folia-api:2.14.0") - implementation("com.github.shynixn.mccoroutine:mccoroutine-folia-core:2.14.0") + implementation("com.github.shynixn.mccoroutine:mccoroutine-folia-api:2.15.0") + implementation("com.github.shynixn.mccoroutine:mccoroutine-folia-core:2.15.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.14.0") - implementation("com.github.shynixn.mccoroutine:mccoroutine-minestom-core:2.14.0") + implementation("com.github.shynixn.mccoroutine:mccoroutine-minestom-api:2.15.0") + implementation("com.github.shynixn.mccoroutine:mccoroutine-minestom-core:2.15.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-sponge-api:2.14.0") - implementation("com.github.shynixn.mccoroutine:mccoroutine-sponge-core:2.14.0") + implementation("com.github.shynixn.mccoroutine:mccoroutine-sponge-api:2.15.0") + implementation("com.github.shynixn.mccoroutine:mccoroutine-sponge-core:2.15.0") } ``` @@ -62,8 +62,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.14.0") - implementation("com.github.shynixn.mccoroutine:mccoroutine-velocity-core:2.14.0") + implementation("com.github.shynixn.mccoroutine:mccoroutine-velocity-api:2.15.0") + implementation("com.github.shynixn.mccoroutine:mccoroutine-velocity-core:2.15.0") } ``` @@ -87,8 +87,8 @@ dependencies { **plugin.yml** ```yaml libraries: - - com.github.shynixn.mccoroutine:mccoroutine-bukkit-api:2.14.0 - - com.github.shynixn.mccoroutine:mccoroutine-bukkit-core:2.14.0 + - com.github.shynixn.mccoroutine:mccoroutine-bukkit-api:2.15.0 + - com.github.shynixn.mccoroutine:mccoroutine-bukkit-core:2.15.0 ``` === "Folia" @@ -96,8 +96,8 @@ dependencies { **plugin.yml** ```yaml libraries: - - com.github.shynixn.mccoroutine:mccoroutine-folia-api:2.14.0 - - com.github.shynixn.mccoroutine:mccoroutine-folia-core:2.14.0 + - com.github.shynixn.mccoroutine:mccoroutine-folia-api:2.15.0 + - com.github.shynixn.mccoroutine:mccoroutine-folia-core:2.15.0 ``` diff --git a/docs/wiki/docs/unittests.md b/docs/wiki/docs/unittests.md index b1cc79f..3250650 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.14.0") + testImplementation("com.github.shynixn.mccoroutine:mccoroutine-bukkit-test:2.15.0") } ``` diff --git a/mccoroutine-bukkit-sample/src/main/resources/plugin.yml b/mccoroutine-bukkit-sample/src/main/resources/plugin.yml index 389b63d..1bc9fea 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.14.0 +version: 2.15.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 4d3b6c0..3bb273e 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.14.0 +version: 2.15.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 7a416ee..d8d30e2 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.14.0") - implementation("com.github.shynixn.mccoroutine:mccoroutine-fabric-core:2.14.0") + implementation("com.github.shynixn.mccoroutine:mccoroutine-fabric-api:2.15.0") + implementation("com.github.shynixn.mccoroutine:mccoroutine-fabric-core:2.15.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-folia-sample/src/main/resources/plugin.yml b/mccoroutine-folia-sample/src/main/resources/plugin.yml index 5bce914..0611a8f 100644 --- a/mccoroutine-folia-sample/src/main/resources/plugin.yml +++ b/mccoroutine-folia-sample/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ name: MCCoroutine-Sample -version: 2.14.0 +version: 2.15.0 author: Shynixn main: com.github.shynixn.mccoroutine.folia.sample.MCCoroutineSamplePlugin folia-supported: true diff --git a/mccoroutine-minestom-sample/src/main/resources/extension.json b/mccoroutine-minestom-sample/src/main/resources/extension.json index d942b08..7ab67cc 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.14.0" + "version": "2.15.0" } diff --git a/mccoroutine-sponge-sample/src/main/resources/mcmod.info b/mccoroutine-sponge-sample/src/main/resources/mcmod.info index a092236..7ce66e9 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.14.0", + "version": "2.15.0", "description": "MCCoroutineSample is sample plugin to use MCCoroutine in Sponge.", "authorList": [ "Shynixn"