diff --git a/build.gradle.kts b/build.gradle.kts index 24527c2..03ae31f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -19,8 +19,8 @@ repositories { val exposedVersion = "0.54.0" dependencies { compileOnly("io.papermc.paper:paper-api:1.21.10-R0.1-SNAPSHOT") - compileOnly("org.jetbrains.kotlin:kotlin-stdlib") - compileOnly("net.hareworks:kommand-lib:1.1") + implementation("org.jetbrains.kotlin:kotlin-stdlib") + implementation("net.hareworks:kommand-lib:1.1") implementation("net.kyori:adventure-api:4.17.0") implementation("net.kyori:adventure-text-minimessage:4.17.0") implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.1") @@ -37,7 +37,13 @@ tasks { archiveBaseName.set("SimplyMCDB") } shadowJar { - minimize() + minimize { + exclude(dependency("org.jetbrains.exposed:exposed-core")) + exclude(dependency("org.jetbrains.exposed:exposed-dao")) + exclude(dependency("org.jetbrains.exposed:exposed-jdbc")) + exclude(dependency("org.jetbrains.exposed:exposed-kotlin-datetime")) + exclude(dependency("org.postgresql:postgresql")) + } archiveClassifier.set("min") relocate("de.tr7zw.changeme.nbtapi", "net.hareworks.simplymcdb.libs.nbtapi") } @@ -52,12 +58,4 @@ paper { authors = listOf( "Hare-K02" ) - serverDependencies { - register("kommand-lib") { - load = PaperPluginDescription.RelativeLoadOrder.BEFORE - } - register("permits-lib") { - load = PaperPluginDescription.RelativeLoadOrder.BEFORE - } - } } diff --git a/src/main/kotlin/net/hareworks/simplymcdb/Command.kt b/src/main/kotlin/net/hareworks/simplymcdb/Command.kt index 9ae7702..14552ab 100644 --- a/src/main/kotlin/net/hareworks/simplymcdb/Command.kt +++ b/src/main/kotlin/net/hareworks/simplymcdb/Command.kt @@ -197,22 +197,36 @@ public fun registerCommands(plugin: JavaPlugin): KommandLib = literal("check") { executes { - sender.sendMM( + val commandSender = sender + commandSender.sendMM( "${when (App.instance.enabled) { State.ACTIVE -> "●" State.DISCONNECTED -> "■" State.DISABLED -> "○" }} simply-minecraft-database") - sender.sendMM( + commandSender.sendMM( "status: ${when (App.instance.enabled) { State.ACTIVE -> "active" State.DISCONNECTED -> "disconnected" State.DISABLED -> "disabled" }}") - sender.sendMM( - "- database test: ${if (Database.ping()) "success" else "failed"}") - sender.sendMM( + commandSender.sendMM( "- config test: ${if (Config.config.getBoolean("enabled")) "enabled" else "disabled"}") + commandSender.sendMM("- database test: checking...") + + // Run the potentially slow ping off the main thread to avoid freezing the server thread. + App.instance.server.scheduler.runTaskAsynchronously(App.instance, Runnable { + val pingSuccess = try { + Database.ping() + } catch (ex: Exception) { + App.instance.logger.warning("Database ping failed: ${ex.message}") + false + } + App.instance.server.scheduler.runTask(App.instance, Runnable { + commandSender.sendMM( + "- database test result: ${if (pingSuccess) "success" else "failed"}") + }) + }) } }