#2546: reducedDebugInfo state not updating when changing servers

This commit is contained in:
md_5 2018-12-18 11:13:10 +11:00
parent 12a99bd291
commit 865a346903
4 changed files with 60 additions and 1 deletions

View File

@ -20,6 +20,7 @@ import net.md_5.bungee.protocol.packet.Kick;
import net.md_5.bungee.protocol.packet.Respawn; import net.md_5.bungee.protocol.packet.Respawn;
import net.md_5.bungee.protocol.packet.Handshake; import net.md_5.bungee.protocol.packet.Handshake;
import net.md_5.bungee.protocol.packet.EncryptionResponse; import net.md_5.bungee.protocol.packet.EncryptionResponse;
import net.md_5.bungee.protocol.packet.EntityStatus;
import net.md_5.bungee.protocol.packet.LegacyHandshake; import net.md_5.bungee.protocol.packet.LegacyHandshake;
import net.md_5.bungee.protocol.packet.LegacyPing; import net.md_5.bungee.protocol.packet.LegacyPing;
import net.md_5.bungee.protocol.packet.LoginPayloadRequest; import net.md_5.bungee.protocol.packet.LoginPayloadRequest;
@ -158,4 +159,8 @@ public abstract class AbstractPacketHandler
public void handle(LoginPayloadResponse response) throws Exception public void handle(LoginPayloadResponse response) throws Exception
{ {
} }
public void handle(EntityStatus status) throws Exception
{
}
} }

View File

@ -16,6 +16,7 @@ import net.md_5.bungee.protocol.packet.Chat;
import net.md_5.bungee.protocol.packet.ClientSettings; import net.md_5.bungee.protocol.packet.ClientSettings;
import net.md_5.bungee.protocol.packet.EncryptionRequest; import net.md_5.bungee.protocol.packet.EncryptionRequest;
import net.md_5.bungee.protocol.packet.EncryptionResponse; import net.md_5.bungee.protocol.packet.EncryptionResponse;
import net.md_5.bungee.protocol.packet.EntityStatus;
import net.md_5.bungee.protocol.packet.Handshake; import net.md_5.bungee.protocol.packet.Handshake;
import net.md_5.bungee.protocol.packet.KeepAlive; import net.md_5.bungee.protocol.packet.KeepAlive;
import net.md_5.bungee.protocol.packet.Kick; import net.md_5.bungee.protocol.packet.Kick;
@ -171,6 +172,12 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_12_1, 0x4A ), map( ProtocolConstants.MINECRAFT_1_12_1, 0x4A ),
map( ProtocolConstants.MINECRAFT_1_13, 0x4E ) map( ProtocolConstants.MINECRAFT_1_13, 0x4E )
); );
TO_CLIENT.registerPacket(
EntityStatus.class,
map( ProtocolConstants.MINECRAFT_1_8, 0x1A ),
map( ProtocolConstants.MINECRAFT_1_9, 0x1B ),
map( ProtocolConstants.MINECRAFT_1_13, 0x1C )
);
TO_SERVER.registerPacket( TO_SERVER.registerPacket(
KeepAlive.class, KeepAlive.class,

View File

@ -0,0 +1,43 @@
package net.md_5.bungee.protocol.packet;
import io.netty.buffer.ByteBuf;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import net.md_5.bungee.protocol.AbstractPacketHandler;
import net.md_5.bungee.protocol.DefinedPacket;
@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class EntityStatus extends DefinedPacket
{
public static final byte DEBUG_INFO_REDUCED = 22;
public static final byte DEBUG_INFO_NORMAL = 23;
//
private int entityId;
private byte status;
@Override
public void read(ByteBuf buf)
{
entityId = buf.readInt();
status = buf.readByte();
}
@Override
public void write(ByteBuf buf)
{
buf.writeInt( entityId );
buf.writeByte( status );
}
@Override
public void handle(AbstractPacketHandler handler) throws Exception
{
handler.handle( this );
}
}

View File

@ -35,6 +35,7 @@ import net.md_5.bungee.protocol.PacketWrapper;
import net.md_5.bungee.protocol.Protocol; import net.md_5.bungee.protocol.Protocol;
import net.md_5.bungee.protocol.ProtocolConstants; import net.md_5.bungee.protocol.ProtocolConstants;
import net.md_5.bungee.protocol.packet.EncryptionRequest; import net.md_5.bungee.protocol.packet.EncryptionRequest;
import net.md_5.bungee.protocol.packet.EntityStatus;
import net.md_5.bungee.protocol.packet.Handshake; import net.md_5.bungee.protocol.packet.Handshake;
import net.md_5.bungee.protocol.packet.Kick; import net.md_5.bungee.protocol.packet.Kick;
import net.md_5.bungee.protocol.packet.Login; import net.md_5.bungee.protocol.packet.Login;
@ -206,7 +207,7 @@ public class ServerConnector extends PacketHandler
user.setClientEntityId( login.getEntityId() ); user.setClientEntityId( login.getEntityId() );
user.setServerEntityId( login.getEntityId() ); user.setServerEntityId( login.getEntityId() );
// Set tab list size, this sucks balls, TODO: what shall we do about packet mutability // Set tab list size, TODO: what shall we do about packet mutability
Login modLogin = new Login( login.getEntityId(), login.getGameMode(), (byte) login.getDimension(), login.getDifficulty(), Login modLogin = new Login( login.getEntityId(), login.getGameMode(), (byte) login.getDimension(), login.getDifficulty(),
(byte) user.getPendingConnection().getListener().getTabListSize(), login.getLevelType(), login.isReducedDebugInfo() ); (byte) user.getPendingConnection().getListener().getTabListSize(), login.getLevelType(), login.isReducedDebugInfo() );
@ -245,6 +246,9 @@ public class ServerConnector extends PacketHandler
} }
user.getSentBossBars().clear(); user.getSentBossBars().clear();
// Update debug info from login packet
user.unsafe().sendPacket( new EntityStatus( user.getClientEntityId(), login.isReducedDebugInfo() ? EntityStatus.DEBUG_INFO_REDUCED : EntityStatus.DEBUG_INFO_NORMAL ) );
user.setDimensionChange( true ); user.setDimensionChange( true );
if ( login.getDimension() == user.getDimension() ) if ( login.getDimension() == user.getDimension() )
{ {