13
0
geforkt von Mirrors/Velocity

Ensure the reset packet is not sent when Forge isn't expecting it.

Fixes #69
Dieser Commit ist enthalten in:
Daniel Naylor 2018-09-10 18:12:01 +01:00
Ursprung 56a50c60b5
Commit df637cd598
2 geänderte Dateien mit 20 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -82,6 +82,12 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
if (existingConnection == null) { if (existingConnection == null) {
// Strap on the play session handler // Strap on the play session handler
connection.getPlayer().getConnection().setSessionHandler(new ClientPlaySessionHandler(server, connection.getPlayer())); connection.getPlayer().getConnection().setSessionHandler(new ClientPlaySessionHandler(server, connection.getPlayer()));
// This is for legacy Forge servers - during first connection the FML handshake will transition to complete regardless
// Thus, we need to ensure that a reset packet is ALWAYS sent on first switch.
//
// The call will handle if the player is not a Forge player appropriately.
connection.getPlayer().getConnection().setCanSendLegacyFMLResetPacket(true);
} else { } else {
// The previous server connection should become obsolete. // The previous server connection should become obsolete.
// Before we remove it, if the server we are departing is modded, we must always reset the client state. // Before we remove it, if the server we are departing is modded, we must always reset the client state.

Datei anzeigen

@ -214,8 +214,21 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
player.getConnection().flush(); player.getConnection().flush();
player.getConnectedServer().getMinecraftConnection().flush(); player.getConnectedServer().getMinecraftConnection().flush();
player.getConnectedServer().setHasCompletedJoin(true); player.getConnectedServer().setHasCompletedJoin(true);
if (player.getConnectedServer().isLegacyForge()) {
// We only need to indicate we can send a reset packet if we complete a handshake, that is,
// logged onto a Forge server.
//
// The special case is if we log onto a Vanilla server as our first server, FML will treat this
// as complete and **will** need a reset packet sending at some point. We will handle this
// during initial player connection if the player is detected to be forge.
//
// This is why we use an if statement rather than the result of VelocityServerConnection#isLegacyForge()
// because we don't want to set it false if this is a first connection to a Vanilla server.
//
// See LoginSessionHandler#handle for where the counterpart to this method is
player.getConnection().setCanSendLegacyFMLResetPacket(true); player.getConnection().setCanSendLegacyFMLResetPacket(true);
} }
}
public List<UUID> getServerBossBars() { public List<UUID> getServerBossBars() {
return serverBossBars; return serverBossBars;