summaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorSho Sakuma <me@m1sk9.dev>2026-02-06 18:43:19 +0900
committerSho Sakuma <me@m1sk9.dev>2026-02-06 18:43:19 +0900
commit5edc4a18217aa9f330eef50372d48ab1eec5becf (patch)
treed4268b6458475d42402cc9d7c4e8ca28c5425880 /engine
parent7f5f826eaf00edd30e116d5940dd139a9e1b04a5 (diff)
downloadLunaticChat-5edc4a18217aa9f330eef50372d48ab1eec5becf.tar.gz
LunaticChat-5edc4a18217aa9f330eef50372d48ab1eec5becf.tar.bz2
LunaticChat-5edc4a18217aa9f330eef50372d48ab1eec5becf.zip
feat: Add global chat protocol
Diffstat (limited to 'engine')
-rw-r--r--engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/protocol/PluginMessage.kt20
-rw-r--r--engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/protocol/PluginMessageCodec.kt7
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")
}
}