diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/AbstractPacketHandler.java b/protocol/src/main/java/net/md_5/bungee/protocol/AbstractPacketHandler.java index 4383dbb53f..70a7c51dd8 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/AbstractPacketHandler.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/AbstractPacketHandler.java @@ -40,6 +40,7 @@ import net.md_5.bungee.protocol.packet.StartConfiguration; import net.md_5.bungee.protocol.packet.StatusRequest; import net.md_5.bungee.protocol.packet.StatusResponse; +import net.md_5.bungee.protocol.packet.StoreCookie; import net.md_5.bungee.protocol.packet.Subtitle; import net.md_5.bungee.protocol.packet.SystemChat; import net.md_5.bungee.protocol.packet.TabCompleteRequest; @@ -47,6 +48,7 @@ import net.md_5.bungee.protocol.packet.Team; import net.md_5.bungee.protocol.packet.Title; import net.md_5.bungee.protocol.packet.TitleTimes; +import net.md_5.bungee.protocol.packet.Transfer; import net.md_5.bungee.protocol.packet.ViewDistance; public abstract class AbstractPacketHandler @@ -243,4 +245,12 @@ public void handle(StartConfiguration startConfiguration) throws Exception public void handle(FinishConfiguration finishConfiguration) throws Exception { } + + public void handle(Transfer transfer) throws Exception + { + } + + public void handle(StoreCookie storeCookie) throws Exception + { + } } diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java b/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java index cc08447cbc..ae8d787a63 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java @@ -46,6 +46,7 @@ import net.md_5.bungee.protocol.packet.StartConfiguration; import net.md_5.bungee.protocol.packet.StatusRequest; import net.md_5.bungee.protocol.packet.StatusResponse; +import net.md_5.bungee.protocol.packet.StoreCookie; import net.md_5.bungee.protocol.packet.Subtitle; import net.md_5.bungee.protocol.packet.SystemChat; import net.md_5.bungee.protocol.packet.TabCompleteRequest; @@ -53,6 +54,7 @@ import net.md_5.bungee.protocol.packet.Team; import net.md_5.bungee.protocol.packet.Title; import net.md_5.bungee.protocol.packet.TitleTimes; +import net.md_5.bungee.protocol.packet.Transfer; import net.md_5.bungee.protocol.packet.ViewDistance; public enum Protocol @@ -90,7 +92,9 @@ public enum Protocol map( ProtocolConstants.MINECRAFT_1_19_1, 0x20 ), map( ProtocolConstants.MINECRAFT_1_19_3, 0x1F ), map( ProtocolConstants.MINECRAFT_1_19_4, 0x23 ), - map( ProtocolConstants.MINECRAFT_1_20_2, 0x24 ) + map( ProtocolConstants.MINECRAFT_1_20_2, 0x24 ), + map( ProtocolConstants.MINECRAFT_1_20_5, 0x25 ) + ); TO_CLIENT.registerPacket( Login.class, @@ -106,7 +110,9 @@ public enum Protocol map( ProtocolConstants.MINECRAFT_1_19_1, 0x25 ), map( ProtocolConstants.MINECRAFT_1_19_3, 0x24 ), map( ProtocolConstants.MINECRAFT_1_19_4, 0x28 ), - map( ProtocolConstants.MINECRAFT_1_20_2, 0x29 ) + map( ProtocolConstants.MINECRAFT_1_20_2, 0x29 ), + map( ProtocolConstants.MINECRAFT_1_20_5, 42 ) + ); TO_CLIENT.registerPacket( Chat.class, Chat::new, @@ -136,7 +142,8 @@ public enum Protocol map( ProtocolConstants.MINECRAFT_1_19_3, 0x3D ), map( ProtocolConstants.MINECRAFT_1_19_4, 0x41 ), map( ProtocolConstants.MINECRAFT_1_20_2, 0x43 ), - map( ProtocolConstants.MINECRAFT_1_20_3, 0x45 ) + map( ProtocolConstants.MINECRAFT_1_20_3, 0x45 ), + map( ProtocolConstants.MINECRAFT_1_20_5, 0x46 ) ); TO_CLIENT.registerPacket( BossBar.class, @@ -195,7 +202,8 @@ public enum Protocol map( ProtocolConstants.MINECRAFT_1_19_3, 0x54 ), map( ProtocolConstants.MINECRAFT_1_19_4, 0x58 ), map( ProtocolConstants.MINECRAFT_1_20_2, 0x5A ), - map( ProtocolConstants.MINECRAFT_1_20_3, 0x5C ) + map( ProtocolConstants.MINECRAFT_1_20_3, 0x5C ), + map( ProtocolConstants.MINECRAFT_1_20_5, 93 ) ); TO_CLIENT.registerPacket( ScoreboardScore.class, @@ -212,12 +220,14 @@ public enum Protocol map( ProtocolConstants.MINECRAFT_1_19_3, 0x57 ), map( ProtocolConstants.MINECRAFT_1_19_4, 0x5B ), map( ProtocolConstants.MINECRAFT_1_20_2, 0x5D ), - map( ProtocolConstants.MINECRAFT_1_20_3, 0x5F ) + map( ProtocolConstants.MINECRAFT_1_20_3, 0x5F ), + map( ProtocolConstants.MINECRAFT_1_20_5, 96 ) ); TO_CLIENT.registerPacket( ScoreboardScoreReset.class, ScoreboardScoreReset::new, - map( ProtocolConstants.MINECRAFT_1_20_3, 0x42 ) + map( ProtocolConstants.MINECRAFT_1_20_3, 0x42 ), + map( ProtocolConstants.MINECRAFT_1_20_5, 0x43 ) ); TO_CLIENT.registerPacket( ScoreboardDisplay.class, @@ -234,7 +244,9 @@ public enum Protocol map( ProtocolConstants.MINECRAFT_1_19_3, 0x4D ), map( ProtocolConstants.MINECRAFT_1_19_4, 0x51 ), map( ProtocolConstants.MINECRAFT_1_20_2, 0x53 ), - map( ProtocolConstants.MINECRAFT_1_20_3, 0x55 ) + map( ProtocolConstants.MINECRAFT_1_20_3, 0x55 ), + map( ProtocolConstants.MINECRAFT_1_20_5, 0x56 ) + ); TO_CLIENT.registerPacket( Team.class, @@ -251,7 +263,8 @@ public enum Protocol map( ProtocolConstants.MINECRAFT_1_19_3, 0x56 ), map( ProtocolConstants.MINECRAFT_1_19_4, 0x5A ), map( ProtocolConstants.MINECRAFT_1_20_2, 0x5C ), - map( ProtocolConstants.MINECRAFT_1_20_3, 0x5E ) + map( ProtocolConstants.MINECRAFT_1_20_3, 0x5E ), + map( ProtocolConstants.MINECRAFT_1_20_5, 95 ) ); TO_CLIENT.registerPacket( PluginMessage.class, @@ -268,7 +281,9 @@ public enum Protocol map( ProtocolConstants.MINECRAFT_1_19_1, 0x16 ), map( ProtocolConstants.MINECRAFT_1_19_3, 0x15 ), map( ProtocolConstants.MINECRAFT_1_19_4, 0x17 ), - map( ProtocolConstants.MINECRAFT_1_20_2, 0x18 ) + map( ProtocolConstants.MINECRAFT_1_20_2, 0x18 ), + map( ProtocolConstants.MINECRAFT_1_20_5, 25 ) + ); TO_CLIENT.registerPacket( Kick.class, @@ -285,7 +300,8 @@ public enum Protocol map( ProtocolConstants.MINECRAFT_1_19_1, 0x19 ), map( ProtocolConstants.MINECRAFT_1_19_3, 0x17 ), map( ProtocolConstants.MINECRAFT_1_19_4, 0x1A ), - map( ProtocolConstants.MINECRAFT_1_20_2, 0x1B ) + map( ProtocolConstants.MINECRAFT_1_20_2, 0x1B ), + map( ProtocolConstants.MINECRAFT_1_20_5, 28 ) ); TO_CLIENT.registerPacket( Title.class, @@ -303,7 +319,10 @@ public enum Protocol map( ProtocolConstants.MINECRAFT_1_19_3, 0x5B ), map( ProtocolConstants.MINECRAFT_1_19_4, 0x5F ), map( ProtocolConstants.MINECRAFT_1_20_2, 0x61 ), - map( ProtocolConstants.MINECRAFT_1_20_3, 0x63 ) + map( ProtocolConstants.MINECRAFT_1_20_3, 0x63 ), + map( ProtocolConstants.MINECRAFT_1_20_5, 0x64 ) + + ); TO_CLIENT.registerPacket( ClearTitles.class, @@ -323,7 +342,8 @@ public enum Protocol map( ProtocolConstants.MINECRAFT_1_19_3, 0x59 ), map( ProtocolConstants.MINECRAFT_1_19_4, 0x5D ), map( ProtocolConstants.MINECRAFT_1_20_2, 0x5F ), - map( ProtocolConstants.MINECRAFT_1_20_3, 0x61 ) + map( ProtocolConstants.MINECRAFT_1_20_3, 0x61 ), + map( ProtocolConstants.MINECRAFT_1_20_5, 0x62 ) ); TO_CLIENT.registerPacket( TitleTimes.class, @@ -334,7 +354,8 @@ public enum Protocol map( ProtocolConstants.MINECRAFT_1_19_3, 0x5C ), map( ProtocolConstants.MINECRAFT_1_19_4, 0x60 ), map( ProtocolConstants.MINECRAFT_1_20_2, 0x62 ), - map( ProtocolConstants.MINECRAFT_1_20_3, 0x64 ) + map( ProtocolConstants.MINECRAFT_1_20_3, 0x64 ), + map( ProtocolConstants.MINECRAFT_1_20_5, 0x65 ) ); TO_CLIENT.registerPacket( SystemChat.class, @@ -344,7 +365,8 @@ public enum Protocol map( ProtocolConstants.MINECRAFT_1_19_3, 0x60 ), map( ProtocolConstants.MINECRAFT_1_19_4, 0x64 ), map( ProtocolConstants.MINECRAFT_1_20_2, 0x67 ), - map( ProtocolConstants.MINECRAFT_1_20_3, 0x69 ) + map( ProtocolConstants.MINECRAFT_1_20_3, 0x69 ), + map( ProtocolConstants.MINECRAFT_1_20_5, 107 ) ); TO_CLIENT.registerPacket( PlayerListHeaderFooter.class, @@ -365,7 +387,9 @@ public enum Protocol map( ProtocolConstants.MINECRAFT_1_19_3, 0x61 ), map( ProtocolConstants.MINECRAFT_1_19_4, 0x65 ), map( ProtocolConstants.MINECRAFT_1_20_2, 0x68 ), - map( ProtocolConstants.MINECRAFT_1_20_3, 0x6A ) + map( ProtocolConstants.MINECRAFT_1_20_3, 0x6A ), + map( ProtocolConstants.MINECRAFT_1_20_5, 0x6C ) + ); TO_CLIENT.registerPacket( EntityStatus.class, @@ -382,7 +406,8 @@ public enum Protocol map( ProtocolConstants.MINECRAFT_1_19_1, 0x1A ), map( ProtocolConstants.MINECRAFT_1_19_3, 0x19 ), map( ProtocolConstants.MINECRAFT_1_19_4, 0x1C ), - map( ProtocolConstants.MINECRAFT_1_20_2, 0x1D ) + map( ProtocolConstants.MINECRAFT_1_20_2, 0x1D ), + map( ProtocolConstants.MINECRAFT_1_20_3, 0x1E ) ); TO_CLIENT.registerPacket( Commands.class, @@ -408,7 +433,9 @@ public enum Protocol map( ProtocolConstants.MINECRAFT_1_19_1, 0x1D ), map( ProtocolConstants.MINECRAFT_1_19_3, 0x1C ), map( ProtocolConstants.MINECRAFT_1_19_4, 0x1F ), - map( ProtocolConstants.MINECRAFT_1_20_2, 0x20 ) + map( ProtocolConstants.MINECRAFT_1_20_2, 0x20 ), + map( ProtocolConstants.MINECRAFT_1_20_5, 33 ) + ); TO_CLIENT.registerPacket( ViewDistance.class, @@ -422,7 +449,8 @@ public enum Protocol map( ProtocolConstants.MINECRAFT_1_19_3, 0x4B ), map( ProtocolConstants.MINECRAFT_1_19_4, 0x4F ), map( ProtocolConstants.MINECRAFT_1_20_2, 0x51 ), - map( ProtocolConstants.MINECRAFT_1_20_3, 0x53 ) + map( ProtocolConstants.MINECRAFT_1_20_3, 0x53 ), + map( ProtocolConstants.MINECRAFT_1_20_5, 0x61 ) ); TO_CLIENT.registerPacket( ServerData.class, @@ -432,27 +460,42 @@ public enum Protocol map( ProtocolConstants.MINECRAFT_1_19_3, 0x41 ), map( ProtocolConstants.MINECRAFT_1_19_4, 0x45 ), map( ProtocolConstants.MINECRAFT_1_20_2, 0x47 ), - map( ProtocolConstants.MINECRAFT_1_20_3, 0x49 ) + map( ProtocolConstants.MINECRAFT_1_20_3, 0x49 ), + map( ProtocolConstants.MINECRAFT_1_20_5, 0x4A ) ); TO_CLIENT.registerPacket( PlayerListItemRemove.class, PlayerListItemRemove::new, map( ProtocolConstants.MINECRAFT_1_19_3, 0x35 ), map( ProtocolConstants.MINECRAFT_1_19_4, 0x39 ), - map( ProtocolConstants.MINECRAFT_1_20_2, 0x3B ) + map( ProtocolConstants.MINECRAFT_1_20_2, 0x3B ), + map( ProtocolConstants.MINECRAFT_1_20_5, 0x3C ) + ); TO_CLIENT.registerPacket( PlayerListItemUpdate.class, PlayerListItemUpdate::new, map( ProtocolConstants.MINECRAFT_1_19_3, 0x36 ), map( ProtocolConstants.MINECRAFT_1_19_4, 0x3A ), - map( ProtocolConstants.MINECRAFT_1_20_2, 0x3C ) + map( ProtocolConstants.MINECRAFT_1_20_2, 0x3C ), + map( ProtocolConstants.MINECRAFT_1_20_5, 0x3D ) ); TO_CLIENT.registerPacket( StartConfiguration.class, StartConfiguration::new, map( ProtocolConstants.MINECRAFT_1_20_2, 0x65 ), - map( ProtocolConstants.MINECRAFT_1_20_3, 0x67 ) + map( ProtocolConstants.MINECRAFT_1_20_3, 0x67 ), + map( ProtocolConstants.MINECRAFT_1_20_5, 0x68 ) + ); + TO_CLIENT.registerPacket( + StoreCookie.class, + StoreCookie::new, + map( ProtocolConstants.MINECRAFT_1_20_5, 0x6A ) + ); + TO_CLIENT.registerPacket( + Transfer.class, + Transfer::new, + map( ProtocolConstants.MINECRAFT_1_20_5, 0x72 ) ); TO_SERVER.registerPacket( @@ -471,7 +514,8 @@ public enum Protocol map( ProtocolConstants.MINECRAFT_1_19_3, 0x11 ), map( ProtocolConstants.MINECRAFT_1_19_4, 0x12 ), map( ProtocolConstants.MINECRAFT_1_20_2, 0x14 ), - map( ProtocolConstants.MINECRAFT_1_20_3, 0x15 ) + map( ProtocolConstants.MINECRAFT_1_20_3, 0x15 ), + map( ProtocolConstants.MINECRAFT_1_20_5, 22 ) ); TO_SERVER.registerPacket( Chat.class, Chat::new, @@ -538,7 +582,9 @@ public enum Protocol map( ProtocolConstants.MINECRAFT_1_19_3, 0x0C ), map( ProtocolConstants.MINECRAFT_1_19_4, 0x0D ), map( ProtocolConstants.MINECRAFT_1_20_2, 0x0F ), - map( ProtocolConstants.MINECRAFT_1_20_3, 0x10 ) + map( ProtocolConstants.MINECRAFT_1_20_3, 0x10 ), + map( ProtocolConstants.MINECRAFT_1_20_5, 0x11 ) + ); TO_SERVER.registerPacket( StartConfiguration.class, @@ -633,25 +679,46 @@ public enum Protocol { { + + // 1.20.5 0 cookie request clientbount 1 serverbound increment other by 1 TO_CLIENT.registerPacket( PluginMessage.class, PluginMessage::new, - map( ProtocolConstants.MINECRAFT_1_20_2, 0x00 ) + map( ProtocolConstants.MINECRAFT_1_20_2, 0x00 ), + map( ProtocolConstants.MINECRAFT_1_20_5, 0x01 ) + ); TO_CLIENT.registerPacket( Kick.class, Kick::new, - map( ProtocolConstants.MINECRAFT_1_20_2, 0x01 ) + map( ProtocolConstants.MINECRAFT_1_20_2, 0x01 ), + map( ProtocolConstants.MINECRAFT_1_20_5, 0x02 ) + ); TO_CLIENT.registerPacket( FinishConfiguration.class, FinishConfiguration::new, - map( ProtocolConstants.MINECRAFT_1_20_2, 0x02 ) + map( ProtocolConstants.MINECRAFT_1_20_2, 0x02 ), + map( ProtocolConstants.MINECRAFT_1_20_5, 0x03 ) + + ); TO_CLIENT.registerPacket( KeepAlive.class, KeepAlive::new, - map( ProtocolConstants.MINECRAFT_1_20_2, 0x03 ) + map( ProtocolConstants.MINECRAFT_1_20_2, 0x03 ), + map( ProtocolConstants.MINECRAFT_1_20_5, 0x04 ) + + ); + TO_CLIENT.registerPacket( + StoreCookie.class, + StoreCookie::new, + map( ProtocolConstants.MINECRAFT_1_20_5, 0x09 ) + ); + TO_CLIENT.registerPacket( + Transfer.class, + Transfer::new, + map( ProtocolConstants.MINECRAFT_1_20_5, 0x0A ) ); TO_SERVER.registerPacket( @@ -662,17 +729,22 @@ public enum Protocol TO_SERVER.registerPacket( PluginMessage.class, PluginMessage::new, - map( ProtocolConstants.MINECRAFT_1_20_2, 0x01 ) + map( ProtocolConstants.MINECRAFT_1_20_2, 0x01 ), + map( ProtocolConstants.MINECRAFT_1_20_5, 0x02 ) ); TO_SERVER.registerPacket( FinishConfiguration.class, FinishConfiguration::new, - map( ProtocolConstants.MINECRAFT_1_20_2, 0x02 ) + map( ProtocolConstants.MINECRAFT_1_20_2, 0x02 ), + map( ProtocolConstants.MINECRAFT_1_20_5, 0x03 ) + ); TO_SERVER.registerPacket( KeepAlive.class, KeepAlive::new, - map( ProtocolConstants.MINECRAFT_1_20_2, 0x03 ) + map( ProtocolConstants.MINECRAFT_1_20_2, 0x03 ), + map( ProtocolConstants.MINECRAFT_1_20_5, 0x04 ) + ); } }; diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/ProtocolConstants.java b/protocol/src/main/java/net/md_5/bungee/protocol/ProtocolConstants.java index 6cb4c798ec..a7cc34a980 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/ProtocolConstants.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/ProtocolConstants.java @@ -6,7 +6,7 @@ public class ProtocolConstants { - private static final boolean SNAPSHOT_SUPPORT = Boolean.getBoolean( "net.md_5.bungee.protocol.snapshot" ); + private static final boolean SNAPSHOT_SUPPORT = true || Boolean.getBoolean( "net.md_5.bungee.protocol.snapshot" ); public static final int MINECRAFT_1_8 = 47; public static final int MINECRAFT_1_9 = 107; public static final int MINECRAFT_1_9_1 = 108; @@ -45,6 +45,7 @@ public class ProtocolConstants public static final int MINECRAFT_1_20 = 763; public static final int MINECRAFT_1_20_2 = 764; public static final int MINECRAFT_1_20_3 = 765; + public static final int MINECRAFT_1_20_5 = 1073741996; public static final List SUPPORTED_VERSIONS; public static final List SUPPORTED_VERSION_IDS; @@ -108,8 +109,7 @@ public class ProtocolConstants if ( SNAPSHOT_SUPPORT ) { - // supportedVersions.add( "1.20.x" ); - // supportedVersionIds.add( ProtocolConstants.MINECRAFT_1_20_3 ); + supportedVersionIds.add( ProtocolConstants.MINECRAFT_1_20_5 ); } SUPPORTED_VERSIONS = supportedVersions.build(); diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/EncryptionRequest.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/EncryptionRequest.java index a29524ca81..2c167475cc 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/EncryptionRequest.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/EncryptionRequest.java @@ -19,6 +19,7 @@ public class EncryptionRequest extends DefinedPacket private String serverId; private byte[] publicKey; private byte[] verifyToken; + private boolean shouldAuthenticate; @Override public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) @@ -26,6 +27,10 @@ public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protoco serverId = readString( buf ); publicKey = readArray( buf ); verifyToken = readArray( buf ); + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_5 ) + { + shouldAuthenticate = buf.readBoolean(); + } } @Override @@ -34,6 +39,10 @@ public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protoc writeString( serverId, buf ); writeArray( publicKey, buf ); writeArray( verifyToken, buf ); + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_5 ) + { + buf.writeBoolean( shouldAuthenticate ); + } } @Override diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Login.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/Login.java index f110c65568..24f3b31afe 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Login.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/Login.java @@ -41,6 +41,7 @@ public class Login extends DefinedPacket private boolean flat; private Location deathLocation; private int portalCooldown; + private boolean secureProfile; @Override public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) @@ -135,7 +136,13 @@ public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protoco dimension = readString( buf ); worldName = readString( buf ); seed = buf.readLong(); - gameMode = buf.readUnsignedByte(); + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_5 ) + { + gameMode = buf.readByte(); + } else + { + gameMode = buf.readUnsignedByte(); + } previousGameMode = buf.readByte(); } if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16 ) @@ -154,6 +161,11 @@ public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protoco { portalCooldown = readVarInt( buf ); } + + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_5 ) + { + secureProfile = buf.readBoolean(); + } } @Override @@ -275,6 +287,11 @@ public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protoc { writeVarInt( portalCooldown, buf ); } + + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_5 ) + { + buf.writeBoolean( secureProfile ); + } } @Override diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/ServerData.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/ServerData.java index d3427f38d8..f9f485e4ab 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/ServerData.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/ServerData.java @@ -33,7 +33,7 @@ public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protoco { if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_4 ) { - icon = DefinedPacket.readArray( buf ); + icon = readArray( buf ); } else { icon = readString( buf ); @@ -45,7 +45,7 @@ public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protoco preview = buf.readBoolean(); } - if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_1 ) + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_1 && protocolVersion < ProtocolConstants.MINECRAFT_1_20_5 ) { enforceSecure = buf.readBoolean(); } @@ -76,7 +76,7 @@ public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protoc buf.writeBoolean( true ); if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_4 ) { - DefinedPacket.writeArray( (byte[]) icon, buf ); + writeArray( (byte[]) icon, buf ); } else { writeString( (String) icon, buf ); @@ -91,7 +91,7 @@ public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protoc buf.writeBoolean( preview ); } - if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_1 ) + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_1 && protocolVersion < ProtocolConstants.MINECRAFT_1_20_5 ) { buf.writeBoolean( enforceSecure ); } diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/StoreCookie.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/StoreCookie.java new file mode 100644 index 0000000000..7a728a04eb --- /dev/null +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/StoreCookie.java @@ -0,0 +1,41 @@ +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; +import net.md_5.bungee.protocol.ProtocolConstants; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode(callSuper = false) +public class StoreCookie extends DefinedPacket +{ + + private String key; + private byte[] data; + + @Override + public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) + { + key = readString( buf ); + data = readArray( buf, 5120 ); + } + + @Override + public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) + { + writeString( key, buf ); + writeArray( data, buf ); + } + + @Override + public void handle(AbstractPacketHandler handler) throws Exception + { + handler.handle( this ); + } +} diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Transfer.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/Transfer.java new file mode 100644 index 0000000000..891eedfade --- /dev/null +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/Transfer.java @@ -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; +import net.md_5.bungee.protocol.ProtocolConstants; + + +@Data +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode(callSuper = false) +public class Transfer extends DefinedPacket +{ + + private String host; + private int port; + + @Override + public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) + { + host = readString( buf ); + port = readVarInt( buf ); + } + + @Override + public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) + { + writeString( host, buf ); + writeVarInt( port, buf ); + } + + @Override + public void handle(AbstractPacketHandler handler) throws Exception + { + handler.handle( this ); + } + +} diff --git a/proxy/src/main/java/net/md_5/bungee/EncryptionUtil.java b/proxy/src/main/java/net/md_5/bungee/EncryptionUtil.java index de12a5651a..fb497ca0cd 100644 --- a/proxy/src/main/java/net/md_5/bungee/EncryptionUtil.java +++ b/proxy/src/main/java/net/md_5/bungee/EncryptionUtil.java @@ -73,7 +73,8 @@ public static EncryptionRequest encryptRequest() byte[] pubKey = keys.getPublic().getEncoded(); byte[] verify = new byte[ 4 ]; random.nextBytes( verify ); - return new EncryptionRequest( hash, pubKey, verify ); + // always auth for now + return new EncryptionRequest( hash, pubKey, verify, true ); } public static boolean check(PlayerPublicKey publicKey, UUID uuid) throws GeneralSecurityException diff --git a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java index dc6a5a8fd9..193a20578a 100644 --- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java +++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java @@ -243,7 +243,7 @@ public static void handleLogin(ProxyServer bungee, ChannelWrapper ch, UserConnec // Set tab list size, TODO: what shall we do about packet mutability Login modLogin = new Login( login.getEntityId(), login.isHardcore(), login.getGameMode(), login.getPreviousGameMode(), login.getWorldNames(), login.getDimensions(), login.getDimension(), login.getWorldName(), login.getSeed(), login.getDifficulty(), (byte) user.getPendingConnection().getListener().getTabListSize(), login.getLevelType(), login.getViewDistance(), login.getSimulationDistance(), login.isReducedDebugInfo(), login.isNormalRespawn(), login.isLimitedCrafting(), login.isDebug(), login.isFlat(), login.getDeathLocation(), - login.getPortalCooldown() ); + login.getPortalCooldown(), login.isSecureProfile() ); user.unsafe().sendPacket( modLogin ); diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java index b1b087aa16..80b69e7071 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java @@ -109,6 +109,8 @@ public void sendPacket(DefinedPacket packet) private boolean legacy; @Getter private String extraDataInHandshake = ""; + @Getter + private boolean transferred; private UserConnection userCon; @Override @@ -349,6 +351,8 @@ public void handle(Handshake handshake) throws Exception ch.setProtocol( Protocol.STATUS ); break; case 2: + case 3: // transferred + this.transferred = handshake.getRequestedProtocol() == 3; // Login bungee.getLogger().log( Level.INFO, "{0} has connected", this ); thisState = State.USERNAME; diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java index 9a47f2ec4c..2bf92a03a3 100644 --- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java @@ -86,6 +86,8 @@ public static EntityMap getEntityMap(int version) return EntityMap_1_16_2.INSTANCE_1_20_2; case ProtocolConstants.MINECRAFT_1_20_3: return EntityMap_1_16_2.INSTANCE_1_20_3; + case ProtocolConstants.MINECRAFT_1_20_5: + return EntityMap_1_16_2.INSTANCE_1_20_5; } throw new RuntimeException( "Version " + version + " has no entity map" ); } diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_16_2.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_16_2.java index 007957a8c8..8a8063a279 100644 --- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_16_2.java +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_16_2.java @@ -22,6 +22,7 @@ class EntityMap_1_16_2 extends EntityMap static final EntityMap_1_16_2 INSTANCE_1_19_4 = new EntityMap_1_16_2( 0x03, 0x30 ); static final EntityMap_1_16_2 INSTANCE_1_20_2 = new EntityMap_1_16_2( -1, 0x33 ); static final EntityMap_1_16_2 INSTANCE_1_20_3 = new EntityMap_1_16_2( -1, 0x34 ); + static final EntityMap_1_16_2 INSTANCE_1_20_5 = new EntityMap_1_16_2( -1, 111 ); // private final int spawnPlayerId; private final int spectateId;