summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/chat/handler/DirectMessageHandler.kt9
-rw-r--r--platform-paper/src/test/kotlin/dev/m1sk9/lunaticChat/paper/chat/handler/DirectMessageHandlerTest.kt2
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)