Skip to content

Commit

Permalink
Fix for edgecase FML|HS packet desynchronization (PaperMC#948)
Browse files Browse the repository at this point in the history
* Fix for edgecase FML|HS packet desynchronization

* Change approach for FML packet desynchronization edge case
  • Loading branch information
DEv0on authored Feb 15, 2023
1 parent 8761d02 commit cd35e8f
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import com.velocitypowered.proxy.connection.backend.BackendConnectionPhases;
import com.velocitypowered.proxy.connection.backend.BungeeCordMessageResponder;
import com.velocitypowered.proxy.connection.backend.VelocityServerConnection;
import com.velocitypowered.proxy.connection.forge.legacy.LegacyForgeConstants;
import com.velocitypowered.proxy.protocol.MinecraftPacket;
import com.velocitypowered.proxy.protocol.StateRegistry;
import com.velocitypowered.proxy.protocol.packet.BossBar;
Expand Down Expand Up @@ -277,7 +278,14 @@ public boolean handle(TabCompleteRequest packet) {

@Override
public boolean handle(PluginMessage packet) {
VelocityServerConnection serverConn = player.getConnectedServer();
// Handling edge case when packet with FML client handshake (state COMPLETE)
// arrives after JoinGame packet from destination server
VelocityServerConnection serverConn =
(player.getConnectedServer() == null
&& packet.getChannel().equals(
LegacyForgeConstants.FORGE_LEGACY_HANDSHAKE_CHANNEL))
? player.getConnectionInFlight() : player.getConnectedServer();

MinecraftConnection backendConn = serverConn != null ? serverConn.getConnection() : null;
if (serverConn != null && backendConn != null) {
if (backendConn.getState() != StateRegistry.PLAY) {
Expand Down

0 comments on commit cd35e8f

Please sign in to comment.