diff options
| author | Sho Sakuma <me@m1sk9.dev> | 2026-02-11 05:56:17 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-11 05:56:17 +0900 |
| commit | 944342294fb574caed734944c739231b372ca163 (patch) | |
| tree | a19835d67a8cd62d95e41d853e371f13004c78d2 /platform-paper/src | |
| parent | 0032eeeb52492070f34faeba2b2ab62250e777ca (diff) | |
| parent | 71f63153304dc17a5c5a5ba9625397be6287edb6 (diff) | |
| download | LunaticChat-0.9.0.tar.gz LunaticChat-0.9.0.tar.bz2 LunaticChat-0.9.0.zip | |
Merge pull request #99 from m1sk9/improve/lcv-status-commandv0.9.0
feat: UI/UX Improvements for the `/lcv status` Command
Diffstat (limited to 'platform-paper/src')
4 files changed, 148 insertions, 101 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 a4fb838..6ebb4f4 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 @@ -16,6 +15,7 @@ import dev.m1sk9.lunaticChat.paper.velocity.VelocityConnectionManager import io.papermc.paper.command.brigadier.CommandSourceStack import io.papermc.paper.command.brigadier.Commands import net.kyori.adventure.text.Component +import net.kyori.adventure.text.event.HoverEvent import net.kyori.adventure.text.format.NamedTextColor /** @@ -29,7 +29,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 +45,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 @@ -62,96 +60,133 @@ class VelocityStatusCommand( val stateMessage = when (state) { VelocityConnectionManager.ConnectionState.DISCONNECTED -> { - Component.text("Disconnected", NamedTextColor.GRAY) + Component + .text(languageManager.getMessage("velocity.state.disconnected"), NamedTextColor.GRAY) + .hoverEvent( + HoverEvent.showText( + Component.text(languageManager.getMessage("velocity.hoverInfo.disconnected"), NamedTextColor.GRAY), + ), + ) } VelocityConnectionManager.ConnectionState.HANDSHAKING -> { - Component.text("Handshaking...", NamedTextColor.YELLOW) + Component + .text(languageManager.getMessage("velocity.state.handshaking"), NamedTextColor.YELLOW) + .hoverEvent( + HoverEvent.showText( + Component.text(languageManager.getMessage("velocity.hoverInfo.handshaking"), NamedTextColor.YELLOW), + ), + ) } VelocityConnectionManager.ConnectionState.CONNECTED -> { - Component.text("Connected", NamedTextColor.GREEN) + Component + .text(languageManager.getMessage("velocity.state.connected"), NamedTextColor.GREEN) + .hoverEvent( + HoverEvent.showText( + Component.text(languageManager.getMessage("velocity.hoverInfo.connected"), NamedTextColor.GREEN), + ), + ) } VelocityConnectionManager.ConnectionState.FAILED -> { - Component.text("Failed", NamedTextColor.RED) + Component + .text(languageManager.getMessage("velocity.state.failed"), NamedTextColor.RED) + .hoverEvent( + HoverEvent.showText( + Component.text(languageManager.getMessage("velocity.hoverInfo.failed"), NamedTextColor.RED), + ), + ) } } - // Header - sender.sendMessage( - MessageFormatter.format( - languageManager.getMessage("velocity.status.header"), - ), - ) - - // Paper plugin version - sender.sendMessage( - Component - .text(" • ", NamedTextColor.GRAY) - .append(Component.text("Paper Version: ", NamedTextColor.GRAY)) - .append(Component.text(meta.version, NamedTextColor.AQUA)), - ) - - // Protocol version - sender.sendMessage( - Component - .text(" • ", NamedTextColor.GRAY) - .append(Component.text("Protocol Version: ", NamedTextColor.GRAY)) - .append(Component.text(ProtocolVersion.version, NamedTextColor.AQUA)), - ) - - // Connection state - sender.sendMessage( - Component - .text(" • ", NamedTextColor.GRAY) - .append(Component.text("Connection State: ", NamedTextColor.GRAY)) - .append(stateMessage), - ) - - // Velocity version (if connected) - velocityConnectionManager.getVelocityVersion()?.let { velocityVersion -> - sender.sendMessage( + val connectionStatus: List<Component?> = + listOf( + // Paper plugin version Component .text(" • ", NamedTextColor.GRAY) - .append(Component.text("Velocity Version: ", NamedTextColor.GRAY)) - .append(Component.text(velocityVersion, NamedTextColor.AQUA)), - ) - } - - // Error message (if failed) - velocityConnectionManager.getLastError()?.let { error -> - sender.sendMessage( + .append(Component.text("${languageManager.getMessage("velocity.status.label.paperVersion")}: ", NamedTextColor.GRAY)) + .append(Component.text(meta.version, NamedTextColor.AQUA)), + // Velocity version (if connected) + velocityConnectionManager.getVelocityVersion()?.let { velocityVersion -> + Component + .text(" • ", NamedTextColor.GRAY) + .append( + Component.text("${languageManager.getMessage("velocity.status.label.velocityVersion")}: ", NamedTextColor.GRAY), + ).append(Component.text(velocityVersion, NamedTextColor.AQUA)) + }, + // Protocol version Component .text(" • ", NamedTextColor.GRAY) - .append(Component.text("Error: ", NamedTextColor.GRAY)) - .append(Component.text(error, NamedTextColor.RED)), + .append(Component.text("${languageManager.getMessage("velocity.status.label.protocolVersion")}: ", NamedTextColor.GRAY)) + .append(Component.text(ProtocolVersion.version, NamedTextColor.AQUA)), + // Connection state + Component + .text(" • ", NamedTextColor.GRAY) + .append(Component.text("${languageManager.getMessage("velocity.status.label.connectionState")}: ", NamedTextColor.GRAY)) + .append(stateMessage), + // Error message (if failed) + velocityConnectionManager.getLastError()?.let { error -> + Component + .text(" • ", NamedTextColor.GRAY) + .append(Component.text("${languageManager.getMessage("velocity.status.error")}: ", NamedTextColor.GRAY)) + .append(Component.text(error, NamedTextColor.RED)) + }, + ) + + sender.apply { + // Header + sendMessage( + MessageFormatter.format( + languageManager.getMessage("velocity.status.header"), + ), ) + // Connection status details + connectionStatus.forEach { line -> + line?.let { sendMessage(it) } + } } - // 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("Checking live status...", 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("Online Players: ", NamedTextColor.GRAY)) - .append(Component.text(response.online.toString(), NamedTextColor.YELLOW)), - ) - }.exceptionally { throwable -> - sender.sendMessage( - Component - .text(" ✗ ", NamedTextColor.RED) - .append(Component.text("Live status check failed: ", 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 f19c494..e3dcf91 100644 --- a/platform-paper/src/main/resources/languages/en.yml +++ b/platform-paper/src/main/resources/languages/en.yml @@ -198,14 +198,25 @@ toggle: on: "Enabled" velocity: + state: + disconnected: "Disconnected" + handshaking: "Handshaking..." + connected: "Connected" + failed: "Failed" status: header: "--- LunaticChat Velocity Cooperation Status ---" - paperVersion: "Paper Plugin Version: v{version}" - velocityVersion: "Velocity Plugin Version: v{version}" - protocolVersion: "Protocol Version: v{version}" - connectionState: "Connection State" error: "Error" checkingLiveStatus: "Checking live status..." - liveStatusSuccess: "Live status: Velocity v{version}, Protocol v{protocol}, Online: {online}" 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" + protocolVersion: "Protocol Version" + connectionState: "Connection State" + 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" + 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 ed02f5a..e9894f1 100644 --- a/platform-paper/src/main/resources/languages/ja.yml +++ b/platform-paper/src/main/resources/languages/ja.yml @@ -198,13 +198,25 @@ toggle: off: "無効" velocity: + state: + disconnected: "切断済み" + handshaking: "ハンドシェイク中..." + connected: "接続済み" + failed: "接続失敗" status: header: "--- LunaticChat Velocity 連携ステータス ---" - paperVersion: "Paper プラグインバージョン: v{version}" - velocityVersion: "Velocity プラグインバージョン: v{version}" - protocolVersion: "プロトコルバージョン: v{version}" - connectionState: "接続状態" error: "エラー" checkingLiveStatus: "ライブステータスを確認中..." - liveStatusSuccess: "ライブステータス: Velocity v{version}, プロトコル v{protocol}, オンライン: {online}" liveStatusFailed: "ライブステータスチェックに失敗しました" + consoleNoLiveStatus: "ライブステータスチェックはコンソールからは利用できません (プレイヤーとして実行してください)" + label: + paperVersion: "Paper バージョン" + velocityVersion: "Velocity バージョン" + protocolVersion: "プロトコルバージョン" + connectionState: "接続状態" + onlinePlayers: "オンラインプレイヤー" + hoverInfo: + disconnected: "LunaticChat と Velocity サーバ間の接続が切断されています。再接続するにはサーバを再起動する必要があります" + handshaking: "現在 LunaticChat と Velocity サーバ間の接続を確立中です" + connected: "LunaticChat は Velocity サーバと正常に接続されています" + failed: "LunaticChat と Velocity サーバ間の接続に失敗しました。再接続するにはエラーを解決する必要があります" |
