From 59e57d6d76b693e2862b7b8ac5ef407c67038cbf Mon Sep 17 00:00:00 2001 From: Nlkomaru Date: Sat, 6 Jan 2024 16:21:20 +0900 Subject: [PATCH 1/5] Fix github actions for deploy dokka pages --- .github/workflows/release.yml | 3 ++ .../dev/nikomaru/raceassist/RaceAssistTest.kt | 54 ------------------- .../race/commands/HelpCommandTest.kt | 39 -------------- 3 files changed, 3 insertions(+), 93 deletions(-) delete mode 100644 src/test/kotlin/dev/nikomaru/raceassist/RaceAssistTest.kt delete mode 100644 src/test/kotlin/dev/nikomaru/raceassist/race/commands/HelpCommandTest.kt diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 75fa1fe..000a347 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -50,6 +50,9 @@ jobs: with: # Upload entire repository path: 'build/dokka/html' + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 - uses: release-drafter/release-drafter@v5 id: release-drafter diff --git a/src/test/kotlin/dev/nikomaru/raceassist/RaceAssistTest.kt b/src/test/kotlin/dev/nikomaru/raceassist/RaceAssistTest.kt deleted file mode 100644 index 4b4503e..0000000 --- a/src/test/kotlin/dev/nikomaru/raceassist/RaceAssistTest.kt +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright © 2021-2024 Nikomaru - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package dev.nikomaru.raceassist - -import be.seeseemelk.mockbukkit.MockBukkit -import com.comphenix.protocol.ProtocolLib -import com.comphenix.protocol.ProtocolLibrary -import org.bukkit.Server -import org.junit.jupiter.api.extension.AfterEachCallback -import org.junit.jupiter.api.extension.BeforeEachCallback -import org.junit.jupiter.api.extension.ExtensionContext -import org.koin.core.context.loadKoinModules -import org.koin.dsl.module - -open class RaceAssistTest : BeforeEachCallback, AfterEachCallback { - - private lateinit var server: Server - private lateinit var plugin: RaceAssist - - override fun beforeEach(context: ExtensionContext) { - println("beforeEach() executed before " + context.displayName + "."); - server = MockBukkit.mock() - setupKoin() - } - - override fun afterEach(context: ExtensionContext) { - MockBukkit.unmock() - } - - - private fun setupKoin() { - plugin = MockBukkit.load(RaceAssist::class.java) - val appModule = module { - single { plugin } - single { server } - } - loadKoinModules(appModule) - } -} \ No newline at end of file diff --git a/src/test/kotlin/dev/nikomaru/raceassist/race/commands/HelpCommandTest.kt b/src/test/kotlin/dev/nikomaru/raceassist/race/commands/HelpCommandTest.kt deleted file mode 100644 index fd14a8a..0000000 --- a/src/test/kotlin/dev/nikomaru/raceassist/race/commands/HelpCommandTest.kt +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright © 2021-2024 Nikomaru - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package dev.nikomaru.raceassist.race.commands - -import be.seeseemelk.mockbukkit.ServerMock -import dev.nikomaru.raceassist.RaceAssistTest -import org.junit.jupiter.api.DisplayName -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -import org.koin.test.KoinTest -import org.koin.test.inject - -@ExtendWith(RaceAssistTest::class) -class HelpCommandTest : KoinTest{ - private val server : ServerMock by inject() - - @Test - @DisplayName("コマンドテスト: ra help") - fun sendHelp(){ - val player = server.addPlayer() - val result = player.performCommand("ra help") - assert(result) - } -} \ No newline at end of file From 34dc79c684cdbfb9c23423397e1352124b6721a0 Mon Sep 17 00:00:00 2001 From: Nlkomaru Date: Sat, 6 Jan 2024 16:36:55 +0900 Subject: [PATCH 2/5] Fix github actions for deploy dokka pages --- .github/workflows/release.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 000a347..058049f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,14 +1,18 @@ name: Release Drafter on: + # Runs on pushes targeting the default branch push: - branches: - - master + branches: ["master"] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: permissions: - contents: read + contents: write pages: write id-token: write + pull-requests: write # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. @@ -17,10 +21,7 @@ concurrency: cancel-in-progress: false jobs: - build: - permissions: - contents: write - pull-requests: write + deploy: environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} From 227dd83d71424045ba3d02ce6dfb1ff34040fa2e Mon Sep 17 00:00:00 2001 From: Nlkomaru Date: Sat, 13 Jan 2024 19:36:50 +0900 Subject: [PATCH 3/5] Add test method. --- .github/dependabot.yml | 2 +- .github/workflows/release.yml | 31 +++++++- .github/workflows/test.yml | 25 +++++++ .../dev/nikomaru/raceassist/RaceAssist.kt | 75 +++++++++++-------- .../raceassist/api/core/manager/WebManager.kt | 9 ++- .../raceassist/data/files/RaceUtils.kt | 2 +- .../dev/nikomaru/raceassist/files/Config.kt | 7 +- .../packet/event/HorsePacketSendEvent.kt | 47 ------------ .../raceassist/race/commands/HelpCommand.kt | 20 +---- .../utils/display/LuminescenceShulker.kt | 3 +- .../dev/nikomaru/raceassist/RaceAssistTest.kt | 51 +++++++++++++ .../race/commands/HelpCommandTest.kt | 45 +++++++++++ 12 files changed, 211 insertions(+), 106 deletions(-) create mode 100644 .github/workflows/test.yml delete mode 100644 src/main/kotlin/dev/nikomaru/raceassist/packet/event/HorsePacketSendEvent.kt create mode 100644 src/test/kotlin/dev/nikomaru/raceassist/RaceAssistTest.kt create mode 100644 src/test/kotlin/dev/nikomaru/raceassist/race/commands/HelpCommandTest.kt diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 4d6bd01..bc03f42 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -8,4 +8,4 @@ updates: - package-ecosystem: "gradle" directory: "/" schedule: - interval: "daily" + interval: "weekly" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 058049f..68f09d3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -55,9 +55,38 @@ jobs: id: deployment uses: actions/deploy-pages@v4 + - name: Test with Gradle + run: ./gradlew test + + - name: Publish test results + id: publish-test-results + uses: mikepenz/action-junit-report@v4 + if: success() || failure() + with: + report_paths: '**/build/test-results/test/TEST-*.xml' + - uses: release-drafter/release-drafter@v5 id: release-drafter with: publish: false + footer: | + ## Check summary + + + + + + + + + + + + + + + +
+ Tests 💯Passed ✅Skipped ⏭️Failed ❌
JUnit Test Report${{ steps.publish-test-results.outputs.total }} ran${{ steps.publish-test-results.outputs.passed }} passed${{ steps.publish-test-results.outputs.skipped }} skipped${{ steps.publish-test-results.outputs.failed }} failed
env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..0abc3be --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,25 @@ +name: test + +on: [ pull_request ] + +jobs: + check: + name: Check + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '17' + cache: 'gradle' + - name: Change wrapper permissions + run: chmod +x ./gradlew + - name: Test with Gradle + run: ./gradlew test + - name: Publish test results + uses: mikepenz/action-junit-report@v4 + if: success() || failure() + with: + report_paths: '**/build/test-results/test/TEST-*.xml' \ No newline at end of file diff --git a/src/main/kotlin/dev/nikomaru/raceassist/RaceAssist.kt b/src/main/kotlin/dev/nikomaru/raceassist/RaceAssist.kt index ed0e921..aca01df 100644 --- a/src/main/kotlin/dev/nikomaru/raceassist/RaceAssist.kt +++ b/src/main/kotlin/dev/nikomaru/raceassist/RaceAssist.kt @@ -37,12 +37,12 @@ import dev.nikomaru.raceassist.data.database.BetList import dev.nikomaru.raceassist.data.database.UserAuthData import dev.nikomaru.raceassist.data.files.RaceUtils import dev.nikomaru.raceassist.files.Config +import dev.nikomaru.raceassist.files.ConfigData import dev.nikomaru.raceassist.horse.commands.HorseDetectCommand import dev.nikomaru.raceassist.horse.commands.OwnerDeleteCommand import dev.nikomaru.raceassist.horse.events.HorseBreedEvent import dev.nikomaru.raceassist.horse.events.HorseKillEvent import dev.nikomaru.raceassist.horse.events.HorseTamedEvent -import dev.nikomaru.raceassist.packet.event.HorsePacketSendEvent import dev.nikomaru.raceassist.race.commands.HelpCommand import dev.nikomaru.raceassist.race.commands.ReloadCommand import dev.nikomaru.raceassist.race.commands.audience.AudienceJoinCommand @@ -64,13 +64,11 @@ import dev.nikomaru.raceassist.utils.TestCommand import dev.nikomaru.raceassist.utils.Utils import dev.nikomaru.raceassist.utils.Utils.client import dev.nikomaru.raceassist.utils.coroutines.async -import dev.nikomaru.raceassist.utils.coroutines.minecraft import dev.nikomaru.raceassist.web.WebCommand import dev.nikomaru.raceassist.web.api.WebAPI import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.async import kotlinx.coroutines.withContext -import kotlinx.serialization.ExperimentalSerializationApi import org.bukkit.Server import org.bukkit.command.CommandSender import org.jetbrains.exposed.sql.Database @@ -88,23 +86,32 @@ open class RaceAssist : SuspendingJavaPlugin(), RaceAssistAPI, KoinComponent { val plugin: RaceAssist by inject() val injectServer: Server by inject() + val configData: ConfigData by inject() + + var webServerIsStarted = false - @OptIn(ExperimentalSerializationApi::class) override suspend fun onEnableAsync() { // Plugin startup logic + Lang.load() + loadResources() + settingWebAPI() + } + + override fun onEnable() { api = this setupKoin() - Lang.load() Config.load() settingDatabase() setCommand() - loadResources() -// registerEvents() - HorsePacketSendEvent() - withContext(Dispatchers.minecraft) { - VaultAPI.setupEconomy() + VaultAPI.setupEconomy() + } + + override suspend fun onDisableAsync() { + // Plugin shutdown logic + if (webServerIsStarted) { + WebAPI.stopServer() } - settingWebAPI() + client.close() } private fun setupKoin() { @@ -120,18 +127,24 @@ open class RaceAssist : SuspendingJavaPlugin(), RaceAssistAPI, KoinComponent { } fun settingWebAPI() { - if (Config.config.webAPI != null) { - if (Config.config.mySQL == null) { - plugin.logger.warning("MySQLが設定されていないため、WebAPIを起動できません。") - return - } - launch { - async(Dispatchers.async) { - WebAPI.settingServer() - WebAPI.startServer() - } + if (configData.webAPI == null) { + plugin.logger.warning("WebAPIが設定されていないため、WebAPIを起動できません。") + return + } + + if (configData.mySQL == null) { + plugin.logger.warning("MySQLが設定されていないため、WebAPIを起動できません。") + return + } + + webServerIsStarted = true + launch { + async(Dispatchers.async) { + WebAPI.settingServer() + WebAPI.startServer() } } + } private suspend fun loadResources() { @@ -148,13 +161,13 @@ open class RaceAssist : SuspendingJavaPlugin(), RaceAssistAPI, KoinComponent { } private fun settingDatabase() { - if (Config.config.mySQL != null) { + if (configData.mySQL != null) { Class.forName("com.mysql.cj.jdbc.Driver") Database.connect( - url = "jdbc:mysql://${Config.config.mySQL!!.url}", + url = "jdbc:mysql://${configData.mySQL!!.url}", driver = "com.mysql.cj.jdbc.Driver", - user = Config.config.mySQL!!.username, - password = Config.config.mySQL!!.password, + user = configData.mySQL!!.username, + password = configData.mySQL!!.password, ) transaction { @@ -167,18 +180,13 @@ open class RaceAssist : SuspendingJavaPlugin(), RaceAssistAPI, KoinComponent { ) transaction { + SchemaUtils.create(BetList) } } } - override fun onDisable() { - // Plugin shutdown logic - WebAPI.stopServer() - client.close() - } - private fun setCommand() { val commandManager: PaperCommandManager = PaperCommandManager( @@ -251,11 +259,12 @@ open class RaceAssist : SuspendingJavaPlugin(), RaceAssistAPI, KoinComponent { parse(TestCommand()) } - if (Config.config.webAPI != null) { + if (configData.webAPI != null) { with(annotationParser) { parse(WebCommand()) } } + logger.info("command is registered") } private fun registerEvents() { @@ -300,7 +309,7 @@ open class RaceAssist : SuspendingJavaPlugin(), RaceAssistAPI, KoinComponent { } override fun getWebManager(): WebManager? { - if (Config.config.webAPI == null) return null + if (configData.webAPI == null) return null return WebManager() } diff --git a/src/main/kotlin/dev/nikomaru/raceassist/api/core/manager/WebManager.kt b/src/main/kotlin/dev/nikomaru/raceassist/api/core/manager/WebManager.kt index 8763a9f..482b1f3 100644 --- a/src/main/kotlin/dev/nikomaru/raceassist/api/core/manager/WebManager.kt +++ b/src/main/kotlin/dev/nikomaru/raceassist/api/core/manager/WebManager.kt @@ -18,15 +18,18 @@ package dev.nikomaru.raceassist.api.core.manager import dev.nikomaru.raceassist.data.database.UserAuthData -import dev.nikomaru.raceassist.files.Config +import dev.nikomaru.raceassist.files.ConfigData import dev.nikomaru.raceassist.utils.Utils.toUUID import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.transactions.experimental.newSuspendedTransaction +import org.koin.core.component.KoinComponent +import org.koin.core.component.inject import java.util.* -class WebManager { +class WebManager : KoinComponent { + val configData: ConfigData by inject() fun getAvailable(): Boolean { - return Config.config.webAPI != null + return configData.webAPI != null } suspend fun getRegisteredPlayers(): List { diff --git a/src/main/kotlin/dev/nikomaru/raceassist/data/files/RaceUtils.kt b/src/main/kotlin/dev/nikomaru/raceassist/data/files/RaceUtils.kt index c807465..fc2b421 100644 --- a/src/main/kotlin/dev/nikomaru/raceassist/data/files/RaceUtils.kt +++ b/src/main/kotlin/dev/nikomaru/raceassist/data/files/RaceUtils.kt @@ -37,7 +37,7 @@ import org.koin.core.component.inject import java.util.* object RaceUtils : KoinComponent { - val plugin: RaceAssist by inject() + private val plugin: RaceAssist by inject() fun existsRace(raceId: String): Boolean { diff --git a/src/main/kotlin/dev/nikomaru/raceassist/files/Config.kt b/src/main/kotlin/dev/nikomaru/raceassist/files/Config.kt index ba72e53..b695dc1 100644 --- a/src/main/kotlin/dev/nikomaru/raceassist/files/Config.kt +++ b/src/main/kotlin/dev/nikomaru/raceassist/files/Config.kt @@ -23,6 +23,8 @@ import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json import org.koin.core.component.KoinComponent import org.koin.core.component.inject +import org.koin.core.context.loadKoinModules +import org.koin.dsl.module import java.io.File object Config : KoinComponent { @@ -36,7 +38,10 @@ object Config : KoinComponent { createConfig(file) - config = json.decodeFromString(file.readText()) + val config: ConfigData = json.decodeFromString(file.readText()) + loadKoinModules(module { + single { config } + }) } @OptIn(ExperimentalSerializationApi::class) diff --git a/src/main/kotlin/dev/nikomaru/raceassist/packet/event/HorsePacketSendEvent.kt b/src/main/kotlin/dev/nikomaru/raceassist/packet/event/HorsePacketSendEvent.kt deleted file mode 100644 index f51f8a1..0000000 --- a/src/main/kotlin/dev/nikomaru/raceassist/packet/event/HorsePacketSendEvent.kt +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright © 2021-2024 Nikomaru - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package dev.nikomaru.raceassist.packet.event - -import com.comphenix.protocol.PacketType -import com.comphenix.protocol.ProtocolManager -import com.comphenix.protocol.events.ListenerPriority -import com.comphenix.protocol.events.PacketAdapter -import com.comphenix.protocol.events.PacketEvent -import dev.nikomaru.raceassist.RaceAssist -import org.koin.core.component.KoinComponent -import org.koin.core.component.inject - - -class HorsePacketSendEvent : KoinComponent { - val plugin: RaceAssist by inject() - val protocolManager: ProtocolManager by inject() - - init { - protocolManager.addPacketListener(object : PacketAdapter( - plugin, - ListenerPriority.NORMAL, - PacketType.Play.Server.REL_ENTITY_MOVE_LOOK - ) { - override fun onPacketSending(event: PacketEvent) { - - } - }) - - - } -} \ No newline at end of file diff --git a/src/main/kotlin/dev/nikomaru/raceassist/race/commands/HelpCommand.kt b/src/main/kotlin/dev/nikomaru/raceassist/race/commands/HelpCommand.kt index b7da2ec..f101d19 100644 --- a/src/main/kotlin/dev/nikomaru/raceassist/race/commands/HelpCommand.kt +++ b/src/main/kotlin/dev/nikomaru/raceassist/race/commands/HelpCommand.kt @@ -20,10 +20,9 @@ package dev.nikomaru.raceassist.race.commands import cloud.commandframework.annotations.CommandDescription import cloud.commandframework.annotations.CommandMethod import cloud.commandframework.annotations.CommandPermission -import dev.nikomaru.raceassist.utils.Lang.mm import org.bukkit.command.CommandSender -@CommandMethod("ra|raceassist") +@CommandMethod("ra") class HelpCommand { @CommandMethod("help") @CommandPermission("raceassist.commands.help") @@ -31,20 +30,7 @@ class HelpCommand { fun help(sender: CommandSender) { val message = "コマンドリスト クリックで開く" - sender.sendMessage(mm.deserialize(message)) + sender.sendRichMessage(message) + return } -// -// @CommandMethod("image ") -// suspend fun createImage(sender: CommandSender, -// @Argument(value = "x1") x1: Int, -// @Argument(value = "x2") x2: Int, -// @Argument(value = "y1") y1: Int, -// @Argument(value = "y2") y2: Int) { -// val base64 = Utils.createImage(x1, x2, y1, y2) -// -// File("D:\\download\\racajkghfds.txt").writeText(base64) -// val serializedObject: ByteArray = Base64.getDecoder().decode(base64) -// File("D:\\download\\racajkghfds.png").writeBytes(serializedObject) -// } - } \ No newline at end of file diff --git a/src/main/kotlin/dev/nikomaru/raceassist/utils/display/LuminescenceShulker.kt b/src/main/kotlin/dev/nikomaru/raceassist/utils/display/LuminescenceShulker.kt index f8741ae..efa44ed 100644 --- a/src/main/kotlin/dev/nikomaru/raceassist/utils/display/LuminescenceShulker.kt +++ b/src/main/kotlin/dev/nikomaru/raceassist/utils/display/LuminescenceShulker.kt @@ -23,7 +23,6 @@ import com.comphenix.protocol.events.PacketContainer import com.comphenix.protocol.wrappers.WrappedDataValue import com.comphenix.protocol.wrappers.WrappedDataWatcher import com.comphenix.protocol.wrappers.WrappedDataWatcher.WrappedDataWatcherObject -import dev.nikomaru.raceassist.RaceAssist import dev.nikomaru.raceassist.utils.coroutines.async import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext @@ -37,7 +36,7 @@ import kotlin.random.Random class LuminescenceShulker : KoinComponent { - val protocolManager: ProtocolManager by inject() + private val protocolManager: ProtocolManager by inject() private val ids = arrayListOf() diff --git a/src/test/kotlin/dev/nikomaru/raceassist/RaceAssistTest.kt b/src/test/kotlin/dev/nikomaru/raceassist/RaceAssistTest.kt new file mode 100644 index 0000000..5453ee7 --- /dev/null +++ b/src/test/kotlin/dev/nikomaru/raceassist/RaceAssistTest.kt @@ -0,0 +1,51 @@ +/* + * Copyright © 2021-2024 Nikomaru + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package dev.nikomaru.raceassist + +import be.seeseemelk.mockbukkit.MockBukkit +import be.seeseemelk.mockbukkit.ServerMock +import org.junit.jupiter.api.extension.AfterEachCallback +import org.junit.jupiter.api.extension.BeforeEachCallback +import org.junit.jupiter.api.extension.ExtensionContext +import org.koin.core.context.loadKoinModules +import org.koin.dsl.module + +class RaceAssistTest : BeforeEachCallback, AfterEachCallback { + private lateinit var server: ServerMock + private lateinit var plugin: RaceAssist + + override fun beforeEach(context: ExtensionContext) { + println("beforeEach() executed before " + context.displayName + ".") + server = MockBukkit.mock() + setupKoin() + } + + override fun afterEach(context: ExtensionContext) { + MockBukkit.unmock() + } + + + private fun setupKoin() { + plugin = MockBukkit.load(RaceAssist::class.java) + val appModule = module { + single { plugin } + single { server } + } + loadKoinModules(appModule) + } +} \ No newline at end of file diff --git a/src/test/kotlin/dev/nikomaru/raceassist/race/commands/HelpCommandTest.kt b/src/test/kotlin/dev/nikomaru/raceassist/race/commands/HelpCommandTest.kt new file mode 100644 index 0000000..0791366 --- /dev/null +++ b/src/test/kotlin/dev/nikomaru/raceassist/race/commands/HelpCommandTest.kt @@ -0,0 +1,45 @@ +/* + * Copyright © 2021-2024 Nikomaru + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package dev.nikomaru.raceassist.race.commands + +import be.seeseemelk.mockbukkit.ServerMock +import dev.nikomaru.raceassist.RaceAssistTest +import org.junit.jupiter.api.Assertions.assertNotNull +import org.junit.jupiter.api.DisplayName +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.koin.test.KoinTest +import org.koin.test.inject + +@ExtendWith(RaceAssistTest::class) +class HelpCommandTest : KoinTest { + private val server: ServerMock by inject() + + @Test + @DisplayName("Testing the help command") + fun helpCommandTest() { + val player = server.addPlayer() + player.isOp = true + player.performCommand("ra help") + Thread.sleep(100) + val res = player.nextMessage() + println(res) + assertNotNull(res) + } + +} \ No newline at end of file From 9bc7c55da6b9c270f24dc59577cf4bd2b1095a10 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Feb 2024 15:37:58 +0000 Subject: [PATCH 4/5] Bump com.github.seeseemelk:MockBukkit-v1.20 from 3.58.0 to 3.74.0 Bumps [com.github.seeseemelk:MockBukkit-v1.20](https://github.com/MockBukkit/MockBukkit) from 3.58.0 to 3.74.0. - [Commits](https://github.com/MockBukkit/MockBukkit/compare/v3.58.0...v3.74.0) --- updated-dependencies: - dependency-name: com.github.seeseemelk:MockBukkit-v1.20 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 37efb65..f0aaa25 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -40,7 +40,7 @@ dependencies { val ifVersion = "0.10.11" val junitVersion = "5.10.1" val mockkVersion = "1.13.8" - val mockBukkitVersion = "3.58.0" + val mockBukkitVersion = "3.74.0" val sqliteVersion = "3.44.1.0" val mysqlVersion = "8.0.33" val vaultVersion = "1.7" From cc84307baedd0da4b9f647b4b04256104742d142 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 Feb 2024 15:39:18 +0000 Subject: [PATCH 5/5] Bump org.xerial:sqlite-jdbc from 3.44.1.0 to 3.45.1.0 Bumps [org.xerial:sqlite-jdbc](https://github.com/xerial/sqlite-jdbc) from 3.44.1.0 to 3.45.1.0. - [Release notes](https://github.com/xerial/sqlite-jdbc/releases) - [Changelog](https://github.com/xerial/sqlite-jdbc/blob/master/CHANGELOG) - [Commits](https://github.com/xerial/sqlite-jdbc/compare/3.44.1.0...3.45.1.0) --- updated-dependencies: - dependency-name: org.xerial:sqlite-jdbc dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index f0aaa25..31ff767 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -41,7 +41,7 @@ dependencies { val junitVersion = "5.10.1" val mockkVersion = "1.13.8" val mockBukkitVersion = "3.74.0" - val sqliteVersion = "3.44.1.0" + val sqliteVersion = "3.45.1.0" val mysqlVersion = "8.0.33" val vaultVersion = "1.7" val protocolLibVersion = "5.2.0-SNAPSHOT"