summaryrefslogtreecommitdiff
path: root/platform-paper/src/main
diff options
context:
space:
mode:
authorSho Sakuma <me@m1sk9.dev>2026-02-11 05:21:08 +0900
committerSho Sakuma <me@m1sk9.dev>2026-02-11 05:21:08 +0900
commit90464e38992ac9affd7968f3833d8d3cc948ae1a (patch)
treed5a373d0e54a2410fe6a8503057515a53836f81b /platform-paper/src/main
parent2b2838e9401b3ecf4ec7ec0c642900e015929363 (diff)
downloadLunaticChat-90464e38992ac9affd7968f3833d8d3cc948ae1a.tar.gz
LunaticChat-90464e38992ac9affd7968f3833d8d3cc948ae1a.tar.bz2
LunaticChat-90464e38992ac9affd7968f3833d8d3cc948ae1a.zip
feat: Improve Velocity Integration Errors
Diffstat (limited to 'platform-paper/src/main')
-rw-r--r--platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/ServiceInitializer.kt15
-rw-r--r--platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/command/impl/lcv/VelocityStatusCommand.kt64
-rw-r--r--platform-paper/src/main/resources/languages/en.yml7
-rw-r--r--platform-paper/src/main/resources/languages/ja.yml7
4 files changed, 45 insertions, 48 deletions
diff --git a/platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/ServiceInitializer.kt b/platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/ServiceInitializer.kt
index dc015ed..0af6ed8 100644
--- a/platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/ServiceInitializer.kt
+++ b/platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/ServiceInitializer.kt
@@ -395,24 +395,13 @@ class ServiceInitializer(
}
is VelocityConnectionManager.HandshakeResult.Error -> {
logger.severe("Velocity handshake failed: ${result.message}")
- logger.severe("Disabling plugin due to Velocity integration failure")
- plugin.server.scheduler.runTask(
- plugin,
- Runnable {
- plugin.server.pluginManager.disablePlugin(plugin)
- },
- )
+ logger.severe("Velocity integration is disabled. Use /lcv status to check the status.")
}
}
}.exceptionally { throwable ->
logger.severe("Velocity handshake exception: ${throwable.message}")
+ logger.severe("Velocity integration is disabled. Use /lcv status to check the status.")
throwable.printStackTrace()
- plugin.server.scheduler.runTask(
- plugin,
- Runnable {
- plugin.server.pluginManager.disablePlugin(plugin)
- },
- )
null
}
}
diff --git a/platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/command/impl/lcv/VelocityStatusCommand.kt b/platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/command/impl/lcv/VelocityStatusCommand.kt
index 7845fe8..fbbe113 100644
--- a/platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/command/impl/lcv/VelocityStatusCommand.kt
+++ b/platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/command/impl/lcv/VelocityStatusCommand.kt
@@ -7,7 +7,6 @@ import dev.m1sk9.lunaticChat.engine.protocol.ProtocolVersion
import dev.m1sk9.lunaticChat.paper.LunaticChat
import dev.m1sk9.lunaticChat.paper.command.annotation.Command
import dev.m1sk9.lunaticChat.paper.command.annotation.Permission
-import dev.m1sk9.lunaticChat.paper.command.annotation.PlayerOnly
import dev.m1sk9.lunaticChat.paper.command.core.CommandContext
import dev.m1sk9.lunaticChat.paper.command.core.LunaticCommand
import dev.m1sk9.lunaticChat.paper.i18n.LanguageManager
@@ -29,7 +28,6 @@ import net.kyori.adventure.text.format.NamedTextColor
description = "Velocity integration status",
)
@Permission(LunaticChatPermissionNode.VelocityStatus::class)
-@PlayerOnly
class VelocityStatusCommand(
plugin: LunaticChat,
private val velocityConnectionManager: VelocityConnectionManager,
@@ -46,15 +44,14 @@ class VelocityStatusCommand(
.literal("status")
.executes { ctx ->
val context = wrapContext(ctx)
- checkPlayerOnly(context)?.let { return@executes handleResult(context, it) }
-
val result = execute(context)
handleResult(context, result)
},
)
private fun execute(ctx: CommandContext): CommandResult {
- val sender = ctx.requirePlayer()
+ val sender = ctx.sender
+ val player = ctx.player
val meta = plugin.pluginMeta
// Connection state
@@ -128,32 +125,41 @@ class VelocityStatusCommand(
}
}
- // Live status check (if connected)
+ // Live status check (only available for players when connected)
if (state == VelocityConnectionManager.ConnectionState.CONNECTED) {
- sender.sendMessage(
- Component
- .text(" • ", NamedTextColor.GRAY)
- .append(Component.text(languageManager.getMessage("velocity.status.checkingLiveStatus"), NamedTextColor.YELLOW)),
- )
+ if (player != null) {
+ sender.sendMessage(
+ Component
+ .text(" • ", NamedTextColor.GRAY)
+ .append(Component.text(languageManager.getMessage("velocity.status.checkingLiveStatus"), NamedTextColor.YELLOW)),
+ )
- velocityConnectionManager
- .requestStatus(sender)
- .thenAccept { response ->
- sender.sendMessage(
- Component
- .text(" ✓ ", NamedTextColor.GREEN)
- .append(Component.text("${languageManager.getMessage("velocity.status.label.onlinePlayers")}: ", NamedTextColor.GRAY))
- .append(Component.text(response.online.toString(), NamedTextColor.YELLOW)),
- )
- }.exceptionally { throwable ->
- sender.sendMessage(
- Component
- .text(" ✗ ", NamedTextColor.RED)
- .append(Component.text("${languageManager.getMessage("velocity.status.liveStatusFailed")}: ", NamedTextColor.GRAY))
- .append(Component.text(throwable.message ?: "Unknown error", NamedTextColor.RED)),
- )
- null
- }
+ velocityConnectionManager
+ .requestStatus(player)
+ .thenAccept { response ->
+ sender.sendMessage(
+ Component
+ .text(" ✓ ", NamedTextColor.GREEN)
+ .append(Component.text("${languageManager.getMessage("velocity.status.label.onlinePlayers")}: ", NamedTextColor.GRAY))
+ .append(Component.text(response.online.toString(), NamedTextColor.YELLOW)),
+ )
+ }.exceptionally { throwable ->
+ sender.sendMessage(
+ Component
+ .text(" ✗ ", NamedTextColor.RED)
+ .append(Component.text("${languageManager.getMessage("velocity.status.liveStatusFailed")}: ", NamedTextColor.GRAY))
+ .append(Component.text(throwable.message ?: "Unknown error", NamedTextColor.RED)),
+ )
+ null
+ }
+ } else {
+ // Console cannot perform live status check
+ sender.sendMessage(
+ Component
+ .text(" • ", NamedTextColor.GRAY)
+ .append(Component.text(languageManager.getMessage("velocity.status.consoleNoLiveStatus"), NamedTextColor.GRAY)),
+ )
+ }
}
return CommandResult.Success
diff --git a/platform-paper/src/main/resources/languages/en.yml b/platform-paper/src/main/resources/languages/en.yml
index 06355c6..e3dcf91 100644
--- a/platform-paper/src/main/resources/languages/en.yml
+++ b/platform-paper/src/main/resources/languages/en.yml
@@ -208,6 +208,7 @@ velocity:
error: "Error"
checkingLiveStatus: "Checking live status..."
liveStatusFailed: "Live status check failed"
+ consoleNoLiveStatus: "Live status check is not available from console (execute as a player)"
label:
paperVersion: "Paper Version"
velocityVersion: "Velocity Version"
@@ -216,6 +217,6 @@ velocity:
onlinePlayers: "Online Players"
hoverInfo:
disconnected: "The connection between LunaticChat and the Velocity server is disconnected. A server restart is required to reconnect"
- handshaking: "Currently establishing connection between LunaticChat and the Velocity server. Integration features are unavailable until the connection is complete"
- connected: "LunaticChat is successfully connected to the Velocity server. Integration features are available"
- failed: "Failed to establish connection between LunaticChat and the Velocity server. A server restart is required to reconnect"
+ handshaking: "Currently establishing connection between LunaticChat and the Velocity server"
+ connected: "LunaticChat is successfully connected to the Velocity server"
+ failed: "Failed to establish connection between LunaticChat and the Velocity server. You need to resolve the error to reconnect"
diff --git a/platform-paper/src/main/resources/languages/ja.yml b/platform-paper/src/main/resources/languages/ja.yml
index 1b46354..e9894f1 100644
--- a/platform-paper/src/main/resources/languages/ja.yml
+++ b/platform-paper/src/main/resources/languages/ja.yml
@@ -208,6 +208,7 @@ velocity:
error: "エラー"
checkingLiveStatus: "ライブステータスを確認中..."
liveStatusFailed: "ライブステータスチェックに失敗しました"
+ consoleNoLiveStatus: "ライブステータスチェックはコンソールからは利用できません (プレイヤーとして実行してください)"
label:
paperVersion: "Paper バージョン"
velocityVersion: "Velocity バージョン"
@@ -216,6 +217,6 @@ velocity:
onlinePlayers: "オンラインプレイヤー"
hoverInfo:
disconnected: "LunaticChat と Velocity サーバ間の接続が切断されています。再接続するにはサーバを再起動する必要があります"
- handshaking: "現在 LunaticChat と Velocity サーバ間の接続を確立中です。接続が完了するまで各種連携機能は利用できません"
- connected: "LunaticChat は Velocity サーバと正常に接続されています。各種連携機能が利用可能です"
- failed: "LunaticChat と Velocity サーバ間の接続に失敗しました。再接続するにはサーバを再起動する必要があります"
+ handshaking: "現在 LunaticChat と Velocity サーバ間の接続を確立中です"
+ connected: "LunaticChat は Velocity サーバと正常に接続されています"
+ failed: "LunaticChat と Velocity サーバ間の接続に失敗しました。再接続するにはエラーを解決する必要があります"