summaryrefslogtreecommitdiff
path: root/platform-velocity
diff options
context:
space:
mode:
Diffstat (limited to 'platform-velocity')
-rw-r--r--platform-velocity/build.gradle.kts2
-rw-r--r--platform-velocity/src/main/kotlin/dev/m1sk9/lunaticChat/velocity/messaging/PluginMessageHandler.kt14
-rw-r--r--platform-velocity/src/test/kotlin/dev/m1sk9/lunaticChat/velocity/messaging/PluginMessageHandlerTest.kt3
3 files changed, 8 insertions, 11 deletions
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<ChannelIdentifier>(), any<ByteArray>()) }
}