feat: 依存関係のimplementation、コマンド実行時の非同期化
This commit is contained in:
parent
47e202a613
commit
ae5bc8a0f0
|
|
@ -19,8 +19,8 @@ repositories {
|
||||||
val exposedVersion = "0.54.0"
|
val exposedVersion = "0.54.0"
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly("io.papermc.paper:paper-api:1.21.10-R0.1-SNAPSHOT")
|
compileOnly("io.papermc.paper:paper-api:1.21.10-R0.1-SNAPSHOT")
|
||||||
compileOnly("org.jetbrains.kotlin:kotlin-stdlib")
|
implementation("org.jetbrains.kotlin:kotlin-stdlib")
|
||||||
compileOnly("net.hareworks:kommand-lib:1.1")
|
implementation("net.hareworks:kommand-lib:1.1")
|
||||||
implementation("net.kyori:adventure-api:4.17.0")
|
implementation("net.kyori:adventure-api:4.17.0")
|
||||||
implementation("net.kyori:adventure-text-minimessage:4.17.0")
|
implementation("net.kyori:adventure-text-minimessage:4.17.0")
|
||||||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.1")
|
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.1")
|
||||||
|
|
@ -37,7 +37,13 @@ tasks {
|
||||||
archiveBaseName.set("SimplyMCDB")
|
archiveBaseName.set("SimplyMCDB")
|
||||||
}
|
}
|
||||||
shadowJar {
|
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")
|
archiveClassifier.set("min")
|
||||||
relocate("de.tr7zw.changeme.nbtapi", "net.hareworks.simplymcdb.libs.nbtapi")
|
relocate("de.tr7zw.changeme.nbtapi", "net.hareworks.simplymcdb.libs.nbtapi")
|
||||||
}
|
}
|
||||||
|
|
@ -52,12 +58,4 @@ paper {
|
||||||
authors = listOf(
|
authors = listOf(
|
||||||
"Hare-K02"
|
"Hare-K02"
|
||||||
)
|
)
|
||||||
serverDependencies {
|
|
||||||
register("kommand-lib") {
|
|
||||||
load = PaperPluginDescription.RelativeLoadOrder.BEFORE
|
|
||||||
}
|
|
||||||
register("permits-lib") {
|
|
||||||
load = PaperPluginDescription.RelativeLoadOrder.BEFORE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -197,22 +197,36 @@ public fun registerCommands(plugin: JavaPlugin): KommandLib =
|
||||||
|
|
||||||
literal("check") {
|
literal("check") {
|
||||||
executes {
|
executes {
|
||||||
sender.sendMM(
|
val commandSender = sender
|
||||||
|
commandSender.sendMM(
|
||||||
"${when (App.instance.enabled) {
|
"${when (App.instance.enabled) {
|
||||||
State.ACTIVE -> "<green>●"
|
State.ACTIVE -> "<green>●"
|
||||||
State.DISCONNECTED -> "<yellow>■"
|
State.DISCONNECTED -> "<yellow>■"
|
||||||
State.DISABLED -> "<red>○"
|
State.DISABLED -> "<red>○"
|
||||||
}}<white> simply-minecraft-database")
|
}}<white> simply-minecraft-database")
|
||||||
sender.sendMM(
|
commandSender.sendMM(
|
||||||
"status: ${when (App.instance.enabled) {
|
"status: ${when (App.instance.enabled) {
|
||||||
State.ACTIVE -> "<green>active"
|
State.ACTIVE -> "<green>active"
|
||||||
State.DISCONNECTED -> "<yellow>disconnected"
|
State.DISCONNECTED -> "<yellow>disconnected"
|
||||||
State.DISABLED -> "<red>disabled"
|
State.DISABLED -> "<red>disabled"
|
||||||
}}")
|
}}")
|
||||||
sender.sendMM(
|
commandSender.sendMM(
|
||||||
"<gray>- <white>database test: ${if (Database.ping()) "success" else "failed"}")
|
|
||||||
sender.sendMM(
|
|
||||||
"<gray>- <white>config test: ${if (Config.config.getBoolean("enabled")) "enabled" else "disabled"}")
|
"<gray>- <white>config test: ${if (Config.config.getBoolean("enabled")) "enabled" else "disabled"}")
|
||||||
|
commandSender.sendMM("<gray>- <white>database test: <yellow>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(
|
||||||
|
"<gray>- <white>database test result: ${if (pingSuccess) "success" else "failed"}")
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user