From 2b0829856c9a24b90a9248d28c7de84101b83232 Mon Sep 17 00:00:00 2001 From: Sho Sakuma Date: Sat, 4 Apr 2026 20:26:37 +0900 Subject: feat: Improving Velocity's Cycling Compatibility --- platform-velocity/build.gradle.kts | 2 ++ .../lunaticChat/velocity/messaging/PluginMessageHandler.kt | 14 ++++---------- .../velocity/messaging/PluginMessageHandlerTest.kt | 3 ++- 3 files changed, 8 insertions(+), 11 deletions(-) (limited to 'platform-velocity') diff --git a/platform-velocity/build.gradle.kts b/platform-velocity/build.gradle.kts index f6a4e57..dcd9f9a 100644 --- a/platform-velocity/build.gradle.kts +++ b/platform-velocity/build.gradle.kts @@ -4,6 +4,8 @@ plugins { id("com.gradleup.shadow") } +version = findProperty("velocityVersion")?.toString() ?: "0.0.0" + repositories { maven("https://repo.papermc.io/repository/maven-public/") { name = "papermc-repo" diff --git a/platform-velocity/src/main/kotlin/dev/m1sk9/lunaticChat/velocity/messaging/PluginMessageHandler.kt b/platform-velocity/src/main/kotlin/dev/m1sk9/lunaticChat/velocity/messaging/PluginMessageHandler.kt index 74da9f2..382eba4 100644 --- a/platform-velocity/src/main/kotlin/dev/m1sk9/lunaticChat/velocity/messaging/PluginMessageHandler.kt +++ b/platform-velocity/src/main/kotlin/dev/m1sk9/lunaticChat/velocity/messaging/PluginMessageHandler.kt @@ -84,16 +84,7 @@ class PluginMessageHandler( "Plugin=${handshake.pluginVersion}, Protocol=${handshake.protocolMajor}.${handshake.protocolMinor}.${handshake.protocolPatch}", ) - // Plugin version check (exact match required) - val versionMatch = handshake.pluginVersion == pluginVersion - if (!versionMatch) { - val error = "Plugin version mismatch: Paper=${handshake.pluginVersion}, Velocity=$pluginVersion" - logger.error(error) - sendHandshakeResponse(connection, false, error) - return - } - - // Protocol version check (MAJOR.MINOR must match) + // Protocol version check (MAJOR must match, MINOR within supported range) val protocolCompatible = ProtocolVersion.isCompatible( handshake.protocolMajor, @@ -126,6 +117,9 @@ class PluginMessageHandler( compatible = compatible, velocityVersion = pluginVersion, error = error, + protocolMajor = ProtocolVersion.MAJOR, + protocolMinor = ProtocolVersion.MINOR, + protocolPatch = ProtocolVersion.PATCH, ) val data = PluginMessageCodec.encode(response) diff --git a/platform-velocity/src/test/kotlin/dev/m1sk9/lunaticChat/velocity/messaging/PluginMessageHandlerTest.kt b/platform-velocity/src/test/kotlin/dev/m1sk9/lunaticChat/velocity/messaging/PluginMessageHandlerTest.kt index 876eec6..3342331 100644 --- a/platform-velocity/src/test/kotlin/dev/m1sk9/lunaticChat/velocity/messaging/PluginMessageHandlerTest.kt +++ b/platform-velocity/src/test/kotlin/dev/m1sk9/lunaticChat/velocity/messaging/PluginMessageHandlerTest.kt @@ -69,7 +69,7 @@ class PluginMessageHandlerTest { } @Test - fun `onPluginMessage should reject version mismatch handshake`() { + fun `onPluginMessage should accept different plugin version with matching protocol`() { val (handler, _, _) = createHandler(pluginVersion = "0.10.0") val connection = createServerConnection() @@ -85,6 +85,7 @@ class PluginMessageHandlerTest { handler.onPluginMessage(event) + // Should still send a response (successful handshake) verify { connection.sendPluginMessage(any(), any()) } } -- cgit v1.2.1