diff options
| author | Sho Sakuma <me@m1sk9.dev> | 2026-08-05 00:42:20 +0900 |
|---|---|---|
| committer | Sho Sakuma <me@m1sk9.dev> | 2026-08-05 00:42:26 +0900 |
| commit | 8b3a3bf31fd2f9dd384e9b66b8d2033e5e36a877 (patch) | |
| tree | 886050233e2f04592743f02724029562b0a87626 | |
| parent | 2c9b4c83298ea67e2e7b576fd7209b5bc782f23c (diff) | |
| download | LunaticChat-8b3a3bf31fd2f9dd384e9b66b8d2033e5e36a877.tar.gz LunaticChat-8b3a3bf31fd2f9dd384e9b66b8d2033e5e36a877.tar.bz2 LunaticChat-8b3a3bf31fd2f9dd384e9b66b8d2033e5e36a877.zip | |
fix: record the reply target only where /reply can see it
Both commands already record the conversation on the command thread before
queueing the delivery, for the same reason recordRemoteRecipient exists: /reply
reads the target there. Recording it again inside the queued work was not only
redundant but late, re-inserting entries that clearPlayer had already swept - so
lastMessager grew by one dead UUID every time a recipient quit mid-delivery.
Co-Authored-By: Claude <noreply@anthropic.com>
2 files changed, 6 insertions, 5 deletions
diff --git a/platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/chat/handler/DirectMessageHandler.kt b/platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/chat/handler/DirectMessageHandler.kt index 7e9cf1c..2033661 100644 --- a/platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/chat/handler/DirectMessageHandler.kt +++ b/platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/chat/handler/DirectMessageHandler.kt @@ -118,8 +118,11 @@ class DirectMessageHandler( /** * Sends a direct message from one player to another on the same server. - * Handles formatting and recording the conversation. - * Applies romaji-to-Japanese conversion if sender has it enabled. + * Handles formatting, and applies romaji-to-Japanese conversion if sender has it enabled. + * + * The conversation is recorded by the caller via [recordMessage] before the delivery is queued, + * for the same reason as [recordRemoteRecipient]. Recording it here as well would also re-insert + * entries that [clearPlayer] has already swept, if the recipient quits mid-delivery. * * @return true if message was sent successfully */ @@ -128,8 +131,6 @@ class DirectMessageHandler( recipient: Player, message: String, ): Boolean { - recordMessage(sender, recipient) - val senderSettings = settingsManager?.getSettings(sender.uniqueId) val recipientSettings = settingsManager?.getSettings(recipient.uniqueId) diff --git a/platform-paper/src/test/kotlin/dev/m1sk9/lunaticChat/paper/chat/handler/DirectMessageHandlerTest.kt b/platform-paper/src/test/kotlin/dev/m1sk9/lunaticChat/paper/chat/handler/DirectMessageHandlerTest.kt index 27a4b9c..a2ba325 100644 --- a/platform-paper/src/test/kotlin/dev/m1sk9/lunaticChat/paper/chat/handler/DirectMessageHandlerTest.kt +++ b/platform-paper/src/test/kotlin/dev/m1sk9/lunaticChat/paper/chat/handler/DirectMessageHandlerTest.kt @@ -191,7 +191,7 @@ class DirectMessageHandlerTest { val recipient = TestUtils.createMockPlayer(name = "Bob") every { Bukkit.getPlayer(recipient.uniqueId) } returns recipient - sync { handler.sendDirectMessage(sender, recipient, "hi") } + handler.recordMessage(sender, recipient) val target = handler.getReplyTarget(sender) assertIs<ReplyTarget.Local>(target) |
