diff options
| author | Sho Sakuma <me@m1sk9.dev> | 2026-02-07 17:00:51 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-07 17:00:51 +0900 |
| commit | d680eaa8fe7a99ccd25674c1b6933096dc28d5df (patch) | |
| tree | 112c6c20abd69af5c3e6d669419d8d2045044fbb /engine/src/main | |
| parent | 0afd010990b8f73d6db5dfb1be353dcf163a63d3 (diff) | |
| parent | 76198199c24b0d1d31d0dfa74825d1ea0cdfb097 (diff) | |
| download | LunaticChat-d680eaa8fe7a99ccd25674c1b6933096dc28d5df.tar.gz LunaticChat-d680eaa8fe7a99ccd25674c1b6933096dc28d5df.tar.bz2 LunaticChat-d680eaa8fe7a99ccd25674c1b6933096dc28d5df.zip | |
Merge pull request #87 from m1sk9/feat/cross-server-chat
feat: Implementation of Cross-Server Chat
Diffstat (limited to 'engine/src/main')
| -rw-r--r-- | engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/protocol/PluginMessage.kt | 20 | ||||
| -rw-r--r-- | engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/protocol/PluginMessageCodec.kt | 7 |
2 files changed, 27 insertions, 0 deletions
diff --git a/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/protocol/PluginMessage.kt b/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/protocol/PluginMessage.kt index 4f3a572..cee7837 100644 --- a/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/protocol/PluginMessage.kt +++ b/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/protocol/PluginMessage.kt @@ -55,4 +55,24 @@ sealed interface PluginMessage { val protocolVersion: String, val online: Boolean, ) : PluginMessage + + /** + * Global chat message (Paper ↔ Velocity ↔ Paper) + * + * @property messageId UUID for deduplication + * @property serverName Source server identifier + * @property playerId UUID as string + * @property playerName Player name + * @property message Chat message content + * @property timestamp Message timestamp (milliseconds since epoch) + */ + @Serializable + data class GlobalChatMessage( + val messageId: String, + val serverName: String, + val playerId: String, + val playerName: String, + val message: String, + val timestamp: Long = System.currentTimeMillis(), + ) : PluginMessage } diff --git a/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/protocol/PluginMessageCodec.kt b/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/protocol/PluginMessageCodec.kt index 042a7dc..85b51f0 100644 --- a/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/protocol/PluginMessageCodec.kt +++ b/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/protocol/PluginMessageCodec.kt @@ -23,6 +23,7 @@ object PluginMessageCodec { const val HANDSHAKE_RESPONSE = "handshake_response" const val STATUS_REQUEST = "status_request" const val STATUS_RESPONSE = "status_response" + const val GLOBAL_CHAT = "global_chat" } /** @@ -49,6 +50,9 @@ object PluginMessageCodec { is PluginMessage.StatusResponse -> { SubChannel.STATUS_RESPONSE to json.encodeToString(message) } + is PluginMessage.GlobalChatMessage -> { + SubChannel.GLOBAL_CHAT to json.encodeToString(message) + } } dataOut.writeUTF(subChannel) @@ -84,6 +88,9 @@ object PluginMessageCodec { SubChannel.STATUS_RESPONSE -> { json.decodeFromString<PluginMessage.StatusResponse>(messageJson) } + SubChannel.GLOBAL_CHAT -> { + json.decodeFromString<PluginMessage.GlobalChatMessage>(messageJson) + } else -> throw IllegalArgumentException("Unknown sub-channel: $subChannel") } } |
