diff options
| author | Sho Sakuma <me@m1sk9.dev> | 2026-08-02 19:27:51 +0900 |
|---|---|---|
| committer | Sho Sakuma <me@m1sk9.dev> | 2026-08-02 19:27:51 +0900 |
| commit | bf62ebe35653492c123c729ae03cb32d8e20e2e6 (patch) | |
| tree | c5d323fe02e1c7f48a13ecf2a573d98095aebe65 /engine | |
| parent | 232ce55f187d7ec0cea2037d8d285d60465e51ff (diff) | |
| download | LunaticChat-bf62ebe35653492c123c729ae03cb32d8e20e2e6.tar.gz LunaticChat-bf62ebe35653492c123c729ae03cb32d8e20e2e6.tar.bz2 LunaticChat-bf62ebe35653492c123c729ae03cb32d8e20e2e6.zip | |
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 <noreply@anthropic.com>
Diffstat (limited to 'engine')
| -rw-r--r-- | engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/protocol/PluginMessageChannel.kt | 16 |
1 files changed, 16 insertions, 0 deletions
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" +} |
