From af766a578dc035e586f021251149ee25137afd99 Mon Sep 17 00:00:00 2001 From: Seppe Volkaerts Date: Sat, 19 Oct 2024 21:44:17 +0200 Subject: [PATCH] Fix double accept mods screen + disallow mixing mods Signed-off-by: Seppe Volkaerts --- build.gradle.kts | 2 +- .../client/ClientInitConnectionHandler.kt | 26 ++----------------- .../terre/impl/player/PlayerImpl.kt | 2 +- .../terre/impl/player/ServerConnectionImpl.kt | 7 +++++ 4 files changed, 11 insertions(+), 26 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 3b52229..9c8b59f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,6 @@ plugins { kotlin("jvm") version "2.0.20" - kotlin("plugin.serialization") version "2.0.0" + kotlin("plugin.serialization") version "2.0.20" id("org.cadixdev.licenser") version "0.6.1" } diff --git a/proxy/src/main/kotlin/org/lanternpowered/terre/impl/network/client/ClientInitConnectionHandler.kt b/proxy/src/main/kotlin/org/lanternpowered/terre/impl/network/client/ClientInitConnectionHandler.kt index cc9e786..d2f1535 100644 --- a/proxy/src/main/kotlin/org/lanternpowered/terre/impl/network/client/ClientInitConnectionHandler.kt +++ b/proxy/src/main/kotlin/org/lanternpowered/terre/impl/network/client/ClientInitConnectionHandler.kt @@ -20,7 +20,6 @@ import org.lanternpowered.terre.impl.event.TerreEventBus import org.lanternpowered.terre.impl.network.Connection import org.lanternpowered.terre.impl.network.ConnectionHandler import org.lanternpowered.terre.impl.network.Packet -import org.lanternpowered.terre.impl.network.Protocol274 import org.lanternpowered.terre.impl.network.ProtocolRegistry import org.lanternpowered.terre.impl.network.ProtocolTModLoader import org.lanternpowered.terre.impl.network.ProtocolVersions @@ -35,10 +34,7 @@ import org.lanternpowered.terre.impl.network.packet.PasswordResponsePacket import org.lanternpowered.terre.impl.network.packet.PlayerInfoPacket import org.lanternpowered.terre.impl.network.packet.WorldInfoRequestPacket import org.lanternpowered.terre.impl.network.packet.init.InitDisconnectClientPacket -import org.lanternpowered.terre.impl.network.packet.tmodloader.SyncModsDonePacket -import org.lanternpowered.terre.impl.network.packet.tmodloader.SyncModsPacket import org.lanternpowered.terre.impl.player.PlayerImpl -import org.lanternpowered.terre.text.localizedTextOf import org.lanternpowered.terre.text.text import org.lanternpowered.terre.text.textOf import java.util.UUID @@ -53,7 +49,6 @@ internal class ClientInitConnectionHandler( private enum class State { Init, - SyncMods, Handshake, RequestClientInfo, DetectClientPlayerLimit, @@ -150,23 +145,13 @@ internal class ClientInitConnectionHandler( if (result is ClientConnectEvent.Result.Denied) { connection.close(result.reason) } else { - startLogin() + checkState(State.Handshake) + approveConnection() } }, connection.eventLoop) return true } - private fun startLogin() { - checkState(State.Handshake) - if (connection.protocolVersion is ProtocolVersion.TModLoader) { - state = State.SyncMods - connection.send(SyncModsPacket(listOf())) - debug { "P -> C [${connection.remoteAddress}] Sync mods" } - } else { - approveConnection() - } - } - private fun approveConnection() { state = State.RequestClientInfo // Send the approved packet, we just do this with a fixed id for now to receive information @@ -209,13 +194,6 @@ internal class ClientInitConnectionHandler( }, connection.eventLoop) } - override fun handle(packet: SyncModsDonePacket): Boolean { - debug { "P <- C [${connection.remoteAddress}] Finished syncing mods" } - checkState(State.SyncMods) - approveConnection() - return true - } - override fun handle(packet: PasswordResponsePacket): Boolean { debug { "P <- C [${connection.remoteAddress},$name] Password response" } checkState(State.RequestPassword) diff --git a/proxy/src/main/kotlin/org/lanternpowered/terre/impl/player/PlayerImpl.kt b/proxy/src/main/kotlin/org/lanternpowered/terre/impl/player/PlayerImpl.kt index 0acd436..e831b89 100644 --- a/proxy/src/main/kotlin/org/lanternpowered/terre/impl/player/PlayerImpl.kt +++ b/proxy/src/main/kotlin/org/lanternpowered/terre/impl/player/PlayerImpl.kt @@ -449,7 +449,7 @@ internal class PlayerImpl( } } - private fun disconnectAndForget(reason: Text) { + fun disconnectAndForget(reason: Text) { clientConnection.close(reason) serverConnection?.connection?.close() } diff --git a/proxy/src/main/kotlin/org/lanternpowered/terre/impl/player/ServerConnectionImpl.kt b/proxy/src/main/kotlin/org/lanternpowered/terre/impl/player/ServerConnectionImpl.kt index f5e5d44..3e2b9e9 100644 --- a/proxy/src/main/kotlin/org/lanternpowered/terre/impl/player/ServerConnectionImpl.kt +++ b/proxy/src/main/kotlin/org/lanternpowered/terre/impl/player/ServerConnectionImpl.kt @@ -125,6 +125,13 @@ internal class ServerConnectionImpl( } syncMods = mods.isNotEmpty() || previousMods.isNotEmpty() } + if (previousServer != null && syncMods) { + // TODO: Is currently not supported because the tModLoader screen to accept new mods + // isn't showing up after you're already in the world + Terre.logger.error("It is currently not supported to mix mods on the backing servers.") + player.disconnectAndForget(textOf("Mixing mods on backing servers is currently not supported.")) + return + } } if (syncMods) { if (modsPacket == null) {