From bf62ebe35653492c123c729ae03cb32d8e20e2e6 Mon Sep 17 00:00:00 2001 From: Sho Sakuma Date: Sun, 2 Aug 2026 19:27:51 +0900 Subject: refactor: single-source the plugin messaging channel and dedup cache The channel Paper and Velocity talk over was declared in seven places, in two spellings ("lunaticchat:main" and the namespace/name pair), one of them an inline literal in CrossServerChatManager that bypassed even its own file's constant. Renaming it meant finding all seven; missing one leaves both sides compiling and starting, just not talking. It now lives next to the codec that defines the wire format. The echo-suppression cache was likewise written twice, and the copies had already drifted in style - one hand-rolled the expiry sweep, the other used filter/map - while staying semantically identical. Any future change to eviction would have had to land in both, and CrossServerChatManager's copy carried a comment claiming ConcurrentHashMap iterators cannot remove(), which they can. MessageDeduplicationCache documents the one property that surprised the tests written against it: eviction orders by millisecond timestamp, so a burst inside a single millisecond evicts arbitrarily among its members. Co-Authored-By: Claude --- .../lunaticChat/engine/protocol/PluginMessageChannel.kt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/protocol/PluginMessageChannel.kt (limited to 'engine') diff --git a/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/protocol/PluginMessageChannel.kt b/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/protocol/PluginMessageChannel.kt new file mode 100644 index 0000000..85093ed --- /dev/null +++ b/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/protocol/PluginMessageChannel.kt @@ -0,0 +1,16 @@ +package dev.m1sk9.lunaticChat.engine.protocol + +/** + * The plugin messaging channel Paper and Velocity exchange [PluginMessage]s over. + * + * Both sides must agree on this exactly. Declaring it next to the codec keeps a rename from + * silently splitting the two halves of the protocol: a Paper server and a proxy that disagree + * still compile and start, they just stop talking. + */ +object PluginMessageChannel { + const val NAMESPACE = "lunaticchat" + const val NAME = "main" + + /** The channel in Bukkit's `namespace:name` form. */ + const val ID = "$NAMESPACE:$NAME" +} -- cgit v1.2.1