From daf9060561656f468a0ae366e5695f5eb74f48f7 Mon Sep 17 00:00:00 2001 From: Sho Sakuma Date: Mon, 3 Aug 2026 15:12:42 +0900 Subject: refactor: make the direct message failure reason an enum DirectMessageError.reason was a String backed by two constants, so the receiving side matched one case and let everything else fall through to "the target is offline". Adding a third reason on the proxy would have shipped it to Paper servers that silently reported the wrong thing - the one string-keyed dispatch sitting next to a protocol layer whose messages are otherwise a sealed hierarchy with exhaustiveness checking. As an enum, the reader must decide what to show for each case, and CrossServerDirectMessageManager's when no longer needs an else. The wire format is unchanged: kotlinx serializes an enum as its name, so the existing snapshots still decode. What did need care is the reverse direction - a reason from a newer proxy would now fail to parse, where the String version degraded. The property has a default and the codec enables coerceInputValues, so an unknown reason lands on TARGET_OFFLINE, exactly the old else branch. There is a compatibility test for that case. Co-Authored-By: Claude --- .../m1sk9/lunaticChat/paper/velocity/CrossServerDirectMessageManager.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'platform-paper') diff --git a/platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/velocity/CrossServerDirectMessageManager.kt b/platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/velocity/CrossServerDirectMessageManager.kt index ccd8d40..8328ad8 100644 --- a/platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/velocity/CrossServerDirectMessageManager.kt +++ b/platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/velocity/CrossServerDirectMessageManager.kt @@ -132,7 +132,7 @@ class CrossServerDirectMessageManager( val messageKey = when (error.reason) { PluginMessage.DirectMessageError.Reason.SERVER_NOT_FOUND -> "directMessage.remoteServerNotFound" - else -> "directMessage.remoteTargetOffline" + PluginMessage.DirectMessageError.Reason.TARGET_OFFLINE -> "directMessage.remoteTargetOffline" } val text = languageManager.getMessage( -- cgit v1.2.1