Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assign ServerConnection to Player before processing post-login packets #1309

Merged
merged 8 commits into from
Jul 4, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,14 @@ public boolean handle(JoinGamePacket packet) {
smc.setActiveSessionHandler(StateRegistry.PLAY,
new BackendPlaySessionHandler(server, serverConn));

// Clean up disabling auto-read while the connected event was being processed.
smc.setAutoReading(true);

// Now set the connected server.
serverConn.getPlayer().setConnectedServer(serverConn);

// Clean up disabling auto-read while the connected event was being processed.
// Do this after setting the connection, so no incoming packets are processed before
// the API knows which server the player is connected to.
smc.setAutoReading(true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind expanding the comment above this line to include your description (or similar)?


// Send client settings. In 1.20.2+ this is done in the config state.
if (smc.getProtocolVersion().lessThan(ProtocolVersion.MINECRAFT_1_20_2)
&& player.getClientSettingsPacket() != null) {
Expand Down