From 8a1cfadab06ac699c3d3c686831b0c1ebec907f0 Mon Sep 17 00:00:00 2001 From: Outfluencer Date: Sat, 20 Jan 2024 01:59:07 +0100 Subject: [PATCH] init snapshot 24w03a --- .../api/event/PlayerHandshakeEvent.java | 2 +- .../main/java/net/md_5/bungee/Bootstrap.java | 1 - .../protocol/AbstractPacketHandler.java | 102 ++++---- .../bungee/protocol/MinecraftDecoder.java | 3 +- .../net/md_5/bungee/protocol/Protocol.java | 224 ++++++++++++------ .../bungee/protocol/ProtocolConstants.java | 4 +- .../net/md_5/bungee/protocol/TagUtil.java | 2 + .../bungee/protocol/packet/LegacyPing.java | 4 +- .../packet/{ => common}/ClientSettings.java | 10 +- .../packet/{ => common}/KeepAlive.java | 2 +- .../protocol/packet/{ => common}/Kick.java | 2 +- .../packet/{ => common}/PluginMessage.java | 2 +- .../protocol/packet/common/StoreCookie.java | 41 ++++ .../protocol/packet/common/Transfer.java | 43 ++++ .../FinishConfiguration.java | 2 +- .../protocol/packet/{ => game}/BossBar.java | 2 +- .../protocol/packet/{ => game}/Chat.java | 2 +- .../packet/{ => game}/ClearTitles.java | 2 +- .../packet/{ => game}/ClientChat.java | 2 +- .../packet/{ => game}/ClientCommand.java | 2 +- .../packet/{ => game}/ClientStatus.java | 2 +- .../protocol/packet/{ => game}/Commands.java | 6 +- .../packet/{ => game}/EntityStatus.java | 2 +- .../protocol/packet/{ => game}/GameState.java | 2 +- .../protocol/packet/{ => game}/Login.java | 21 +- .../{ => game}/PlayerListHeaderFooter.java | 2 +- .../packet/{ => game}/PlayerListItem.java | 46 ++-- .../{ => game}/PlayerListItemRemove.java | 10 +- .../{ => game}/PlayerListItemUpdate.java | 34 +-- .../protocol/packet/{ => game}/Respawn.java | 2 +- .../packet/{ => game}/ScoreboardDisplay.java | 2 +- .../{ => game}/ScoreboardObjective.java | 4 +- .../packet/{ => game}/ScoreboardScore.java | 6 +- .../{ => game}/ScoreboardScoreReset.java | 2 +- .../packet/{ => game}/ServerData.java | 10 +- .../packet/{ => game}/StartConfiguration.java | 2 +- .../protocol/packet/{ => game}/Subtitle.java | 2 +- .../packet/{ => game}/SystemChat.java | 2 +- .../packet/{ => game}/TabCompleteRequest.java | 2 +- .../{ => game}/TabCompleteResponse.java | 2 +- .../protocol/packet/{ => game}/Team.java | 2 +- .../protocol/packet/{ => game}/Title.java | 4 +- .../packet/{ => game}/TitleTimes.java | 2 +- .../packet/{ => game}/ViewDistance.java | 6 +- .../packet/{ => handshake}/Handshake.java | 2 +- .../packet/{ => login}/EncryptionRequest.java | 11 +- .../{ => login}/EncryptionResponse.java | 2 +- .../packet/{ => login}/LoginAcknowledged.java | 2 +- .../{ => login}/LoginPayloadRequest.java | 2 +- .../{ => login}/LoginPayloadResponse.java | 2 +- .../packet/{ => login}/LoginRequest.java | 3 +- .../packet/{ => login}/LoginSuccess.java | 2 +- .../packet/{ => login}/SetCompression.java | 6 +- .../packet/{ => status}/PingPacket.java | 2 +- .../packet/{ => status}/StatusRequest.java | 2 +- .../packet/{ => status}/StatusResponse.java | 2 +- .../protocol/packet/PluginMessageTest.java | 1 + .../main/java/net/md_5/bungee/BungeeCord.java | 2 +- .../net/md_5/bungee/BungeeServerInfo.java | 2 +- .../java/net/md_5/bungee/BungeeTitle.java | 22 +- .../java/net/md_5/bungee/EncryptionUtil.java | 6 +- .../net/md_5/bungee/ServerConnection.java | 2 +- .../java/net/md_5/bungee/ServerConnector.java | 45 ++-- .../java/net/md_5/bungee/UserConnection.java | 18 +- .../bungee/connection/DownstreamBridge.java | 36 +-- .../bungee/connection/InitialHandler.java | 25 +- .../md_5/bungee/connection/PingHandler.java | 6 +- .../bungee/connection/UpstreamBridge.java | 26 +- .../net/md_5/bungee/entitymap/EntityMap.java | 2 + .../bungee/entitymap/EntityMap_1_16_2.java | 2 + .../md_5/bungee/forge/ForgeClientHandler.java | 2 +- .../forge/ForgeClientHandshakeState.java | 2 +- .../net/md_5/bungee/forge/ForgeConstants.java | 2 +- .../net/md_5/bungee/forge/ForgeLogger.java | 2 +- .../md_5/bungee/forge/ForgeServerHandler.java | 2 +- .../forge/ForgeServerHandshakeState.java | 2 +- .../net/md_5/bungee/forge/ForgeUtils.java | 2 +- .../forge/IForgeClientPacketHandler.java | 2 +- .../forge/IForgeServerPacketHandler.java | 10 +- .../net/md_5/bungee/netty/ChannelWrapper.java | 2 +- .../net/md_5/bungee/tab/ServerUnique.java | 6 +- .../java/net/md_5/bungee/tab/TabList.java | 6 +- 82 files changed, 551 insertions(+), 351 deletions(-) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => common}/ClientSettings.java (89%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => common}/KeepAlive.java (96%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => common}/Kick.java (96%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => common}/PluginMessage.java (98%) create mode 100644 protocol/src/main/java/net/md_5/bungee/protocol/packet/common/StoreCookie.java create mode 100644 protocol/src/main/java/net/md_5/bungee/protocol/packet/common/Transfer.java rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => configuration}/FinishConfiguration.java (93%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => game}/BossBar.java (98%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => game}/Chat.java (97%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => game}/ClearTitles.java (95%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => game}/ClientChat.java (98%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => game}/ClientCommand.java (98%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => game}/ClientStatus.java (94%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => game}/Commands.java (99%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => game}/EntityStatus.java (95%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => game}/GameState.java (95%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => game}/Login.java (94%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => game}/PlayerListHeaderFooter.java (96%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => game}/PlayerListItem.java (66%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => game}/PlayerListItemRemove.java (78%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => game}/PlayerListItemUpdate.java (75%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => game}/Respawn.java (99%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => game}/ScoreboardDisplay.java (96%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => game}/ScoreboardObjective.java (94%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => game}/ScoreboardScore.java (88%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => game}/ScoreboardScoreReset.java (95%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => game}/ServerData.java (91%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => game}/StartConfiguration.java (94%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => game}/Subtitle.java (95%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => game}/SystemChat.java (97%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => game}/TabCompleteRequest.java (98%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => game}/TabCompleteResponse.java (98%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => game}/Team.java (98%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => game}/Title.java (96%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => game}/TitleTimes.java (95%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => game}/ViewDistance.java (82%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => handshake}/Handshake.java (95%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => login}/EncryptionRequest.java (75%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => login}/EncryptionResponse.java (97%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => login}/LoginAcknowledged.java (94%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => login}/LoginPayloadRequest.java (96%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => login}/LoginPayloadResponse.java (96%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => login}/LoginRequest.java (97%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => login}/LoginSuccess.java (97%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => login}/SetCompression.java (85%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => status}/PingPacket.java (93%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => status}/StatusRequest.java (92%) rename protocol/src/main/java/net/md_5/bungee/protocol/packet/{ => status}/StatusResponse.java (94%) diff --git a/api/src/main/java/net/md_5/bungee/api/event/PlayerHandshakeEvent.java b/api/src/main/java/net/md_5/bungee/api/event/PlayerHandshakeEvent.java index 2f7b38d9e4..b8c24f2f7e 100644 --- a/api/src/main/java/net/md_5/bungee/api/event/PlayerHandshakeEvent.java +++ b/api/src/main/java/net/md_5/bungee/api/event/PlayerHandshakeEvent.java @@ -5,7 +5,7 @@ import lombok.ToString; import net.md_5.bungee.api.connection.PendingConnection; import net.md_5.bungee.api.plugin.Event; -import net.md_5.bungee.protocol.packet.Handshake; +import net.md_5.bungee.protocol.packet.handshake.Handshake; /** * Event called to represent a player first making their presence and username diff --git a/bootstrap/src/main/java/net/md_5/bungee/Bootstrap.java b/bootstrap/src/main/java/net/md_5/bungee/Bootstrap.java index 6be22739dd..cd4dcceeda 100644 --- a/bootstrap/src/main/java/net/md_5/bungee/Bootstrap.java +++ b/bootstrap/src/main/java/net/md_5/bungee/Bootstrap.java @@ -11,7 +11,6 @@ public static void main(String[] args) throws Exception System.out.println( "You can check your Java version with the command: java -version" ); return; } - BungeeCordLauncher.main( args ); } } 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..cc346b0f95 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 @@ -1,53 +1,55 @@ package net.md_5.bungee.protocol; -import net.md_5.bungee.protocol.packet.BossBar; -import net.md_5.bungee.protocol.packet.Chat; -import net.md_5.bungee.protocol.packet.ClearTitles; -import net.md_5.bungee.protocol.packet.ClientChat; -import net.md_5.bungee.protocol.packet.ClientCommand; -import net.md_5.bungee.protocol.packet.ClientSettings; -import net.md_5.bungee.protocol.packet.ClientStatus; -import net.md_5.bungee.protocol.packet.Commands; -import net.md_5.bungee.protocol.packet.EncryptionRequest; -import net.md_5.bungee.protocol.packet.EncryptionResponse; -import net.md_5.bungee.protocol.packet.EntityStatus; -import net.md_5.bungee.protocol.packet.FinishConfiguration; -import net.md_5.bungee.protocol.packet.GameState; -import net.md_5.bungee.protocol.packet.Handshake; -import net.md_5.bungee.protocol.packet.KeepAlive; -import net.md_5.bungee.protocol.packet.Kick; import net.md_5.bungee.protocol.packet.LegacyHandshake; import net.md_5.bungee.protocol.packet.LegacyPing; -import net.md_5.bungee.protocol.packet.Login; -import net.md_5.bungee.protocol.packet.LoginAcknowledged; -import net.md_5.bungee.protocol.packet.LoginPayloadRequest; -import net.md_5.bungee.protocol.packet.LoginPayloadResponse; -import net.md_5.bungee.protocol.packet.LoginRequest; -import net.md_5.bungee.protocol.packet.LoginSuccess; -import net.md_5.bungee.protocol.packet.PingPacket; -import net.md_5.bungee.protocol.packet.PlayerListHeaderFooter; -import net.md_5.bungee.protocol.packet.PlayerListItem; -import net.md_5.bungee.protocol.packet.PlayerListItemRemove; -import net.md_5.bungee.protocol.packet.PlayerListItemUpdate; -import net.md_5.bungee.protocol.packet.PluginMessage; -import net.md_5.bungee.protocol.packet.Respawn; -import net.md_5.bungee.protocol.packet.ScoreboardDisplay; -import net.md_5.bungee.protocol.packet.ScoreboardObjective; -import net.md_5.bungee.protocol.packet.ScoreboardScore; -import net.md_5.bungee.protocol.packet.ScoreboardScoreReset; -import net.md_5.bungee.protocol.packet.ServerData; -import net.md_5.bungee.protocol.packet.SetCompression; -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.Subtitle; -import net.md_5.bungee.protocol.packet.SystemChat; -import net.md_5.bungee.protocol.packet.TabCompleteRequest; -import net.md_5.bungee.protocol.packet.TabCompleteResponse; -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.ViewDistance; +import net.md_5.bungee.protocol.packet.common.ClientSettings; +import net.md_5.bungee.protocol.packet.common.KeepAlive; +import net.md_5.bungee.protocol.packet.common.Kick; +import net.md_5.bungee.protocol.packet.common.PluginMessage; +import net.md_5.bungee.protocol.packet.common.StoreCookie; +import net.md_5.bungee.protocol.packet.common.Transfer; +import net.md_5.bungee.protocol.packet.configuration.FinishConfiguration; +import net.md_5.bungee.protocol.packet.game.BossBar; +import net.md_5.bungee.protocol.packet.game.Chat; +import net.md_5.bungee.protocol.packet.game.ClearTitles; +import net.md_5.bungee.protocol.packet.game.ClientChat; +import net.md_5.bungee.protocol.packet.game.ClientCommand; +import net.md_5.bungee.protocol.packet.game.ClientStatus; +import net.md_5.bungee.protocol.packet.game.Commands; +import net.md_5.bungee.protocol.packet.game.EntityStatus; +import net.md_5.bungee.protocol.packet.game.GameState; +import net.md_5.bungee.protocol.packet.game.Login; +import net.md_5.bungee.protocol.packet.game.PlayerListHeaderFooter; +import net.md_5.bungee.protocol.packet.game.PlayerListItem; +import net.md_5.bungee.protocol.packet.game.PlayerListItemRemove; +import net.md_5.bungee.protocol.packet.game.PlayerListItemUpdate; +import net.md_5.bungee.protocol.packet.game.Respawn; +import net.md_5.bungee.protocol.packet.game.ScoreboardDisplay; +import net.md_5.bungee.protocol.packet.game.ScoreboardObjective; +import net.md_5.bungee.protocol.packet.game.ScoreboardScore; +import net.md_5.bungee.protocol.packet.game.ScoreboardScoreReset; +import net.md_5.bungee.protocol.packet.game.ServerData; +import net.md_5.bungee.protocol.packet.game.StartConfiguration; +import net.md_5.bungee.protocol.packet.game.Subtitle; +import net.md_5.bungee.protocol.packet.game.SystemChat; +import net.md_5.bungee.protocol.packet.game.TabCompleteRequest; +import net.md_5.bungee.protocol.packet.game.TabCompleteResponse; +import net.md_5.bungee.protocol.packet.game.Team; +import net.md_5.bungee.protocol.packet.game.Title; +import net.md_5.bungee.protocol.packet.game.TitleTimes; +import net.md_5.bungee.protocol.packet.game.ViewDistance; +import net.md_5.bungee.protocol.packet.handshake.Handshake; +import net.md_5.bungee.protocol.packet.login.EncryptionRequest; +import net.md_5.bungee.protocol.packet.login.EncryptionResponse; +import net.md_5.bungee.protocol.packet.login.LoginAcknowledged; +import net.md_5.bungee.protocol.packet.login.LoginPayloadRequest; +import net.md_5.bungee.protocol.packet.login.LoginPayloadResponse; +import net.md_5.bungee.protocol.packet.login.LoginRequest; +import net.md_5.bungee.protocol.packet.login.LoginSuccess; +import net.md_5.bungee.protocol.packet.login.SetCompression; +import net.md_5.bungee.protocol.packet.status.PingPacket; +import net.md_5.bungee.protocol.packet.status.StatusRequest; +import net.md_5.bungee.protocol.packet.status.StatusResponse; 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/MinecraftDecoder.java b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java index d79d5e5ccc..9a177298a0 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java @@ -35,12 +35,11 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf in, List out) t try { int packetId = DefinedPacket.readVarInt( in ); - DefinedPacket packet = prot.createPacket( packetId, protocolVersion ); + if ( packet != null ) { packet.read( in, protocol, prot.getDirection(), protocolVersion ); - if ( in.isReadable() ) { throw new BadPacketException( "Packet " + protocol + ":" + prot.getDirection() + "/" + packetId + " (" + packet.getClass().getSimpleName() + ") larger than expected, extra bytes: " + in.readableBytes() ); 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..1e599a4dea 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 @@ -9,51 +9,53 @@ import java.util.function.Supplier; import lombok.Data; import lombok.Getter; -import net.md_5.bungee.protocol.packet.BossBar; -import net.md_5.bungee.protocol.packet.Chat; -import net.md_5.bungee.protocol.packet.ClearTitles; -import net.md_5.bungee.protocol.packet.ClientChat; -import net.md_5.bungee.protocol.packet.ClientCommand; -import net.md_5.bungee.protocol.packet.ClientSettings; -import net.md_5.bungee.protocol.packet.Commands; -import net.md_5.bungee.protocol.packet.EncryptionRequest; -import net.md_5.bungee.protocol.packet.EncryptionResponse; -import net.md_5.bungee.protocol.packet.EntityStatus; -import net.md_5.bungee.protocol.packet.FinishConfiguration; -import net.md_5.bungee.protocol.packet.GameState; -import net.md_5.bungee.protocol.packet.Handshake; -import net.md_5.bungee.protocol.packet.KeepAlive; -import net.md_5.bungee.protocol.packet.Kick; -import net.md_5.bungee.protocol.packet.Login; -import net.md_5.bungee.protocol.packet.LoginAcknowledged; -import net.md_5.bungee.protocol.packet.LoginPayloadRequest; -import net.md_5.bungee.protocol.packet.LoginPayloadResponse; -import net.md_5.bungee.protocol.packet.LoginRequest; -import net.md_5.bungee.protocol.packet.LoginSuccess; -import net.md_5.bungee.protocol.packet.PingPacket; -import net.md_5.bungee.protocol.packet.PlayerListHeaderFooter; -import net.md_5.bungee.protocol.packet.PlayerListItem; -import net.md_5.bungee.protocol.packet.PlayerListItemRemove; -import net.md_5.bungee.protocol.packet.PlayerListItemUpdate; -import net.md_5.bungee.protocol.packet.PluginMessage; -import net.md_5.bungee.protocol.packet.Respawn; -import net.md_5.bungee.protocol.packet.ScoreboardDisplay; -import net.md_5.bungee.protocol.packet.ScoreboardObjective; -import net.md_5.bungee.protocol.packet.ScoreboardScore; -import net.md_5.bungee.protocol.packet.ScoreboardScoreReset; -import net.md_5.bungee.protocol.packet.ServerData; -import net.md_5.bungee.protocol.packet.SetCompression; -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.Subtitle; -import net.md_5.bungee.protocol.packet.SystemChat; -import net.md_5.bungee.protocol.packet.TabCompleteRequest; -import net.md_5.bungee.protocol.packet.TabCompleteResponse; -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.ViewDistance; +import net.md_5.bungee.protocol.packet.common.ClientSettings; +import net.md_5.bungee.protocol.packet.common.KeepAlive; +import net.md_5.bungee.protocol.packet.common.Kick; +import net.md_5.bungee.protocol.packet.common.PluginMessage; +import net.md_5.bungee.protocol.packet.common.StoreCookie; +import net.md_5.bungee.protocol.packet.common.Transfer; +import net.md_5.bungee.protocol.packet.configuration.FinishConfiguration; +import net.md_5.bungee.protocol.packet.game.BossBar; +import net.md_5.bungee.protocol.packet.game.Chat; +import net.md_5.bungee.protocol.packet.game.ClearTitles; +import net.md_5.bungee.protocol.packet.game.ClientChat; +import net.md_5.bungee.protocol.packet.game.ClientCommand; +import net.md_5.bungee.protocol.packet.game.Commands; +import net.md_5.bungee.protocol.packet.game.EntityStatus; +import net.md_5.bungee.protocol.packet.game.GameState; +import net.md_5.bungee.protocol.packet.game.Login; +import net.md_5.bungee.protocol.packet.game.PlayerListHeaderFooter; +import net.md_5.bungee.protocol.packet.game.PlayerListItem; +import net.md_5.bungee.protocol.packet.game.PlayerListItemRemove; +import net.md_5.bungee.protocol.packet.game.PlayerListItemUpdate; +import net.md_5.bungee.protocol.packet.game.Respawn; +import net.md_5.bungee.protocol.packet.game.ScoreboardDisplay; +import net.md_5.bungee.protocol.packet.game.ScoreboardObjective; +import net.md_5.bungee.protocol.packet.game.ScoreboardScore; +import net.md_5.bungee.protocol.packet.game.ScoreboardScoreReset; +import net.md_5.bungee.protocol.packet.game.ServerData; +import net.md_5.bungee.protocol.packet.game.StartConfiguration; +import net.md_5.bungee.protocol.packet.game.Subtitle; +import net.md_5.bungee.protocol.packet.game.SystemChat; +import net.md_5.bungee.protocol.packet.game.TabCompleteRequest; +import net.md_5.bungee.protocol.packet.game.TabCompleteResponse; +import net.md_5.bungee.protocol.packet.game.Team; +import net.md_5.bungee.protocol.packet.game.Title; +import net.md_5.bungee.protocol.packet.game.TitleTimes; +import net.md_5.bungee.protocol.packet.game.ViewDistance; +import net.md_5.bungee.protocol.packet.handshake.Handshake; +import net.md_5.bungee.protocol.packet.login.EncryptionRequest; +import net.md_5.bungee.protocol.packet.login.EncryptionResponse; +import net.md_5.bungee.protocol.packet.login.LoginAcknowledged; +import net.md_5.bungee.protocol.packet.login.LoginPayloadRequest; +import net.md_5.bungee.protocol.packet.login.LoginPayloadResponse; +import net.md_5.bungee.protocol.packet.login.LoginRequest; +import net.md_5.bungee.protocol.packet.login.LoginSuccess; +import net.md_5.bungee.protocol.packet.login.SetCompression; +import net.md_5.bungee.protocol.packet.status.PingPacket; +import net.md_5.bungee.protocol.packet.status.StatusRequest; +import net.md_5.bungee.protocol.packet.status.StatusResponse; 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..b9c82dd6aa 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 @@ -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/TagUtil.java b/protocol/src/main/java/net/md_5/bungee/protocol/TagUtil.java index 4be18dfa79..6a5cb37052 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/TagUtil.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/TagUtil.java @@ -227,6 +227,8 @@ public static JsonElement toJson(SpecificTag tag) } return jsonLongArray; + case Tag.TAG_END: + return new JsonObject(); default: throw new IllegalArgumentException( "Unknown NBT tag: " + tag ); } diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/LegacyPing.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/LegacyPing.java index 02de15c92f..502f2991a0 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/LegacyPing.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/LegacyPing.java @@ -18,13 +18,13 @@ public class LegacyPing extends DefinedPacket @Override public void read(ByteBuf buf) { - throw new UnsupportedOperationException( "Not supported yet." ); //To change body of generated methods, choose Tools | Templates. + throw new UnsupportedOperationException( "Not supported yet." ); } @Override public void write(ByteBuf buf) { - throw new UnsupportedOperationException( "Not supported yet." ); //To change body of generated methods, choose Tools | Templates. + throw new UnsupportedOperationException( "Not supported yet." ); } @Override diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/ClientSettings.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/common/ClientSettings.java similarity index 89% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/ClientSettings.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/common/ClientSettings.java index d7d4e6ab4f..90b964da17 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/ClientSettings.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/common/ClientSettings.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.common; import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; @@ -31,12 +31,12 @@ public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protoco { locale = readString( buf, 16 ); viewDistance = buf.readByte(); - chatFlags = protocolVersion >= ProtocolConstants.MINECRAFT_1_9 ? DefinedPacket.readVarInt( buf ) : buf.readUnsignedByte(); + chatFlags = protocolVersion >= ProtocolConstants.MINECRAFT_1_9 ? readVarInt( buf ) : buf.readUnsignedByte(); chatColours = buf.readBoolean(); skinParts = buf.readByte(); if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_9 ) { - mainHand = DefinedPacket.readVarInt( buf ); + mainHand = readVarInt( buf ); } if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_17 ) { @@ -55,7 +55,7 @@ public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protoc buf.writeByte( viewDistance ); if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_9 ) { - DefinedPacket.writeVarInt( chatFlags, buf ); + writeVarInt( chatFlags, buf ); } else { buf.writeByte( chatFlags ); @@ -64,7 +64,7 @@ public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protoc buf.writeByte( skinParts ); if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_9 ) { - DefinedPacket.writeVarInt( mainHand, buf ); + writeVarInt( mainHand, buf ); } if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_17 ) { diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/KeepAlive.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/common/KeepAlive.java similarity index 96% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/KeepAlive.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/common/KeepAlive.java index b004bc4164..f6ffd66dd5 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/KeepAlive.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/common/KeepAlive.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.common; import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Kick.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/common/Kick.java similarity index 96% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/Kick.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/common/Kick.java index 14539b4b87..70a80f8a0d 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Kick.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/common/Kick.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.common; import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/common/PluginMessage.java similarity index 98% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/common/PluginMessage.java index 70b292f039..ac666b49b9 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/common/PluginMessage.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.common; import com.google.common.base.Function; import com.google.common.base.Preconditions; diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/common/StoreCookie.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/common/StoreCookie.java new file mode 100644 index 0000000000..32a398093e --- /dev/null +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/common/StoreCookie.java @@ -0,0 +1,41 @@ +package net.md_5.bungee.protocol.packet.common; + +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/common/Transfer.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/common/Transfer.java new file mode 100644 index 0000000000..b549ab6868 --- /dev/null +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/common/Transfer.java @@ -0,0 +1,43 @@ +package net.md_5.bungee.protocol.packet.common; + +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/protocol/src/main/java/net/md_5/bungee/protocol/packet/FinishConfiguration.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/configuration/FinishConfiguration.java similarity index 93% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/FinishConfiguration.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/configuration/FinishConfiguration.java index 51dee0772a..ba04a818e1 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/FinishConfiguration.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/configuration/FinishConfiguration.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.configuration; import io.netty.buffer.ByteBuf; import lombok.Data; diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/BossBar.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/BossBar.java similarity index 98% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/BossBar.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/game/BossBar.java index 991a1ab9e9..37aa3564c6 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/BossBar.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/BossBar.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.game; import io.netty.buffer.ByteBuf; import java.util.UUID; diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Chat.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/Chat.java similarity index 97% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/Chat.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/game/Chat.java index dc98660973..5c5847ca4b 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Chat.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/Chat.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.game; import io.netty.buffer.ByteBuf; import java.util.UUID; diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/ClearTitles.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/ClearTitles.java similarity index 95% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/ClearTitles.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/game/ClearTitles.java index c37c0285a1..f375ecf10e 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/ClearTitles.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/ClearTitles.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.game; import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/ClientChat.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/ClientChat.java similarity index 98% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/ClientChat.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/game/ClientChat.java index 105c8276f4..5df19271bd 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/ClientChat.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/ClientChat.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.game; import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/ClientCommand.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/ClientCommand.java similarity index 98% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/ClientCommand.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/game/ClientCommand.java index 887ff29f22..c881efc9f5 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/ClientCommand.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/ClientCommand.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.game; import com.google.common.base.Preconditions; import io.netty.buffer.ByteBuf; diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/ClientStatus.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/ClientStatus.java similarity index 94% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/ClientStatus.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/game/ClientStatus.java index 369902ad9b..e8759a7c44 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/ClientStatus.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/ClientStatus.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.game; import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Commands.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/Commands.java similarity index 99% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/Commands.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/game/Commands.java index 069bb52bfe..e2f6ec4fcb 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Commands.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/Commands.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.game; import com.google.common.base.Preconditions; import com.mojang.brigadier.Command; @@ -526,13 +526,13 @@ protected String getKey() @Override protected String read(ByteBuf buf) { - return DefinedPacket.readString( buf ); + return readString( buf ); } @Override protected void write(ByteBuf buf, String t) { - DefinedPacket.writeString( t, buf ); + writeString( t, buf ); } }; diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/EntityStatus.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/EntityStatus.java similarity index 95% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/EntityStatus.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/game/EntityStatus.java index a151c0faa0..b98bacbd21 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/EntityStatus.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/EntityStatus.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.game; import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/GameState.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/GameState.java similarity index 95% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/GameState.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/game/GameState.java index 3c74354b1a..c48e8fd4c4 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/GameState.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/GameState.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.game; import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; 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/game/Login.java similarity index 94% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/Login.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/game/Login.java index f110c65568..fbd64a700c 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/game/Login.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.game; import io.netty.buffer.ByteBuf; import java.util.HashSet; @@ -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/PlayerListHeaderFooter.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/PlayerListHeaderFooter.java similarity index 96% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/PlayerListHeaderFooter.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/game/PlayerListHeaderFooter.java index 98dbae4a90..b45a819b16 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/PlayerListHeaderFooter.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/PlayerListHeaderFooter.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.game; import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/PlayerListItem.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/PlayerListItem.java similarity index 66% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/PlayerListItem.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/game/PlayerListItem.java index 34a12a80ed..b44b737fb7 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/PlayerListItem.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/PlayerListItem.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.game; import io.netty.buffer.ByteBuf; import java.util.UUID; @@ -24,22 +24,22 @@ public class PlayerListItem extends DefinedPacket @Override public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) { - action = Action.values()[DefinedPacket.readVarInt( buf )]; - items = new Item[ DefinedPacket.readVarInt( buf ) ]; + action = Action.values()[readVarInt( buf )]; + items = new Item[ readVarInt( buf ) ]; for ( int i = 0; i < items.length; i++ ) { Item item = items[i] = new Item(); - item.setUuid( DefinedPacket.readUUID( buf ) ); + item.setUuid( readUUID( buf ) ); switch ( action ) { case ADD_PLAYER: - item.username = DefinedPacket.readString( buf ); - item.properties = DefinedPacket.readProperties( buf ); - item.gamemode = DefinedPacket.readVarInt( buf ); - item.ping = DefinedPacket.readVarInt( buf ); + item.username = readString( buf ); + item.properties = readProperties( buf ); + item.gamemode = readVarInt( buf ); + item.ping = readVarInt( buf ); if ( buf.readBoolean() ) { - item.displayName = DefinedPacket.readBaseComponent( buf, protocolVersion ); + item.displayName = readBaseComponent( buf, protocolVersion ); } if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19 ) { @@ -47,15 +47,15 @@ public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protoco } break; case UPDATE_GAMEMODE: - item.gamemode = DefinedPacket.readVarInt( buf ); + item.gamemode = readVarInt( buf ); break; case UPDATE_LATENCY: - item.ping = DefinedPacket.readVarInt( buf ); + item.ping = readVarInt( buf ); break; case UPDATE_DISPLAY_NAME: if ( buf.readBoolean() ) { - item.displayName = DefinedPacket.readBaseComponent( buf, protocolVersion ); + item.displayName = readBaseComponent( buf, protocolVersion ); } } } @@ -64,22 +64,22 @@ public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protoco @Override public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) { - DefinedPacket.writeVarInt( action.ordinal(), buf ); - DefinedPacket.writeVarInt( items.length, buf ); + writeVarInt( action.ordinal(), buf ); + writeVarInt( items.length, buf ); for ( Item item : items ) { - DefinedPacket.writeUUID( item.uuid, buf ); + writeUUID( item.uuid, buf ); switch ( action ) { case ADD_PLAYER: - DefinedPacket.writeString( item.username, buf ); - DefinedPacket.writeProperties( item.properties, buf ); - DefinedPacket.writeVarInt( item.gamemode, buf ); - DefinedPacket.writeVarInt( item.ping, buf ); + writeString( item.username, buf ); + writeProperties( item.properties, buf ); + writeVarInt( item.gamemode, buf ); + writeVarInt( item.ping, buf ); buf.writeBoolean( item.displayName != null ); if ( item.displayName != null ) { - DefinedPacket.writeBaseComponent( item.displayName, buf, protocolVersion ); + writeBaseComponent( item.displayName, buf, protocolVersion ); } if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19 ) { @@ -87,16 +87,16 @@ public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protoc } break; case UPDATE_GAMEMODE: - DefinedPacket.writeVarInt( item.gamemode, buf ); + writeVarInt( item.gamemode, buf ); break; case UPDATE_LATENCY: - DefinedPacket.writeVarInt( item.ping, buf ); + writeVarInt( item.ping, buf ); break; case UPDATE_DISPLAY_NAME: buf.writeBoolean( item.displayName != null ); if ( item.displayName != null ) { - DefinedPacket.writeBaseComponent( item.displayName, buf, protocolVersion ); + writeBaseComponent( item.displayName, buf, protocolVersion ); } break; } diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/PlayerListItemRemove.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/PlayerListItemRemove.java similarity index 78% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/PlayerListItemRemove.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/game/PlayerListItemRemove.java index 498772460a..01027c9a53 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/PlayerListItemRemove.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/PlayerListItemRemove.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.game; import io.netty.buffer.ByteBuf; import java.util.UUID; @@ -20,20 +20,20 @@ public class PlayerListItemRemove extends DefinedPacket @Override public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) { - uuids = new UUID[ DefinedPacket.readVarInt( buf ) ]; + uuids = new UUID[ readVarInt( buf ) ]; for ( int i = 0; i < uuids.length; i++ ) { - uuids[i] = DefinedPacket.readUUID( buf ); + uuids[i] = readUUID( buf ); } } @Override public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) { - DefinedPacket.writeVarInt( uuids.length, buf ); + writeVarInt( uuids.length, buf ); for ( UUID uuid : uuids ) { - DefinedPacket.writeUUID( uuid, buf ); + writeUUID( uuid, buf ); } } diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/PlayerListItemUpdate.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/PlayerListItemUpdate.java similarity index 75% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/PlayerListItemUpdate.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/game/PlayerListItemUpdate.java index f6708b062f..3acb5d3a0b 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/PlayerListItemUpdate.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/PlayerListItemUpdate.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.game; import io.netty.buffer.ByteBuf; import java.util.EnumSet; @@ -9,7 +9,7 @@ import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.PlayerPublicKey; import net.md_5.bungee.protocol.ProtocolConstants; -import net.md_5.bungee.protocol.packet.PlayerListItem.Item; +import net.md_5.bungee.protocol.packet.game.PlayerListItem.Item; @Data @NoArgsConstructor @@ -25,19 +25,19 @@ public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protoco { actions = readEnumSet( PlayerListItemUpdate.Action.class, buf ); - items = new Item[ DefinedPacket.readVarInt( buf ) ]; + items = new Item[ readVarInt( buf ) ]; for ( int i = 0; i < items.length; i++ ) { Item item = items[i] = new Item(); - item.setUuid( DefinedPacket.readUUID( buf ) ); + item.setUuid( readUUID( buf ) ); for ( Action action : actions ) { switch ( action ) { case ADD_PLAYER: - item.username = DefinedPacket.readString( buf ); - item.properties = DefinedPacket.readProperties( buf ); + item.username = readString( buf ); + item.properties = readProperties( buf ); break; case INITIALIZE_CHAT: if ( buf.readBoolean() ) @@ -47,18 +47,18 @@ public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protoco } break; case UPDATE_GAMEMODE: - item.gamemode = DefinedPacket.readVarInt( buf ); + item.gamemode = readVarInt( buf ); break; case UPDATE_LISTED: item.listed = buf.readBoolean(); break; case UPDATE_LATENCY: - item.ping = DefinedPacket.readVarInt( buf ); + item.ping = readVarInt( buf ); break; case UPDATE_DISPLAY_NAME: if ( buf.readBoolean() ) { - item.displayName = DefinedPacket.readBaseComponent( buf, protocolVersion ); + item.displayName = readBaseComponent( buf, protocolVersion ); } break; } @@ -69,19 +69,19 @@ public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protoco @Override public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) { - DefinedPacket.writeEnumSet( actions, PlayerListItemUpdate.Action.class, buf ); + writeEnumSet( actions, PlayerListItemUpdate.Action.class, buf ); - DefinedPacket.writeVarInt( items.length, buf ); + writeVarInt( items.length, buf ); for ( Item item : items ) { - DefinedPacket.writeUUID( item.uuid, buf ); + writeUUID( item.uuid, buf ); for ( Action action : actions ) { switch ( action ) { case ADD_PLAYER: - DefinedPacket.writeString( item.username, buf ); - DefinedPacket.writeProperties( item.properties, buf ); + writeString( item.username, buf ); + writeProperties( item.properties, buf ); break; case INITIALIZE_CHAT: buf.writeBoolean( item.chatSessionId != null ); @@ -94,19 +94,19 @@ public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protoc } break; case UPDATE_GAMEMODE: - DefinedPacket.writeVarInt( item.gamemode, buf ); + writeVarInt( item.gamemode, buf ); break; case UPDATE_LISTED: buf.writeBoolean( item.listed ); break; case UPDATE_LATENCY: - DefinedPacket.writeVarInt( item.ping, buf ); + writeVarInt( item.ping, buf ); break; case UPDATE_DISPLAY_NAME: buf.writeBoolean( item.displayName != null ); if ( item.displayName != null ) { - DefinedPacket.writeBaseComponent( item.displayName, buf, protocolVersion ); + writeBaseComponent( item.displayName, buf, protocolVersion ); } break; } diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Respawn.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/Respawn.java similarity index 99% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/Respawn.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/game/Respawn.java index e6b1b0c929..48a771a7cd 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Respawn.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/Respawn.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.game; import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/ScoreboardDisplay.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/ScoreboardDisplay.java similarity index 96% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/ScoreboardDisplay.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/game/ScoreboardDisplay.java index cdaabb7554..d0a522ada1 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/ScoreboardDisplay.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/ScoreboardDisplay.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.game; import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/ScoreboardObjective.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/ScoreboardObjective.java similarity index 94% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/ScoreboardObjective.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/game/ScoreboardObjective.java index a37617fd46..9420a24c88 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/ScoreboardObjective.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/ScoreboardObjective.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.game; import io.netty.buffer.ByteBuf; import java.util.Locale; @@ -69,7 +69,7 @@ public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protoc } if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_3 ) { - writeNullable( numberFormat, (s, b) -> DefinedPacket.writeNumberFormat( s, b, protocolVersion ), buf ); + writeNullable( numberFormat, (s, b) -> writeNumberFormat( s, b, protocolVersion ), buf ); } } } diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/ScoreboardScore.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/ScoreboardScore.java similarity index 88% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/ScoreboardScore.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/game/ScoreboardScore.java index d77826a7a9..f366fdbcfa 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/ScoreboardScore.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/ScoreboardScore.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.game; import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; @@ -66,8 +66,8 @@ public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protoc } if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_3 ) { - writeNullable( displayName, (s, b) -> DefinedPacket.writeBaseComponent( s, b, protocolVersion ), buf ); - writeNullable( numberFormat, (s, b) -> DefinedPacket.writeNumberFormat( s, b, protocolVersion ), buf ); + writeNullable( displayName, (s, b) -> writeBaseComponent( s, b, protocolVersion ), buf ); + writeNullable( numberFormat, (s, b) -> writeNumberFormat( s, b, protocolVersion ), buf ); } } diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/ScoreboardScoreReset.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/ScoreboardScoreReset.java similarity index 95% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/ScoreboardScoreReset.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/game/ScoreboardScoreReset.java index 4ba7f9a7f8..b08c16fb06 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/ScoreboardScoreReset.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/ScoreboardScoreReset.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.game; import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; 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/game/ServerData.java similarity index 91% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/ServerData.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/game/ServerData.java index d3427f38d8..da2ab83530 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/game/ServerData.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.game; import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; @@ -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/StartConfiguration.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/StartConfiguration.java similarity index 94% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/StartConfiguration.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/game/StartConfiguration.java index cebbd394e2..54bc8c4afa 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/StartConfiguration.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/StartConfiguration.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.game; import io.netty.buffer.ByteBuf; import lombok.Data; diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Subtitle.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/Subtitle.java similarity index 95% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/Subtitle.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/game/Subtitle.java index 69e0b84031..d1997061ac 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Subtitle.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/Subtitle.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.game; import io.netty.buffer.ByteBuf; import lombok.Data; diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/SystemChat.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/SystemChat.java similarity index 97% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/SystemChat.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/game/SystemChat.java index 7bad3d2b99..49213b266c 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/SystemChat.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/SystemChat.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.game; import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/TabCompleteRequest.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/TabCompleteRequest.java similarity index 98% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/TabCompleteRequest.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/game/TabCompleteRequest.java index 80e4f85af1..c95aacc19c 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/TabCompleteRequest.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/TabCompleteRequest.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.game; import io.netty.buffer.ByteBuf; import lombok.Data; diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/TabCompleteResponse.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/TabCompleteResponse.java similarity index 98% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/TabCompleteResponse.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/game/TabCompleteResponse.java index 2ea141bc7b..3598936366 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/TabCompleteResponse.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/TabCompleteResponse.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.game; import com.mojang.brigadier.Message; import com.mojang.brigadier.context.StringRange; diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Team.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/Team.java similarity index 98% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/Team.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/game/Team.java index 7a14e6a65a..c9aba43b89 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Team.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/Team.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.game; import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Title.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/Title.java similarity index 96% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/Title.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/game/Title.java index 125cbeb772..445345d397 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Title.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/Title.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.game; import io.netty.buffer.ByteBuf; import lombok.Data; @@ -41,7 +41,7 @@ public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protoco int index = readVarInt( buf ); - // If we're working on 1.10 or lower, increment the value of the index so we pull out the correct value. + // If we're working on 1.10 or lower, increment the value of the index, so we pull out the correct value. if ( protocolVersion <= ProtocolConstants.MINECRAFT_1_10 && index >= 2 ) { index++; diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/TitleTimes.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/TitleTimes.java similarity index 95% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/TitleTimes.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/game/TitleTimes.java index 4252c00f1b..731bb468ec 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/TitleTimes.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/TitleTimes.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.game; import io.netty.buffer.ByteBuf; import lombok.Data; diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/ViewDistance.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/ViewDistance.java similarity index 82% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/ViewDistance.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/game/ViewDistance.java index b693a509af..680da6e2b2 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/ViewDistance.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/game/ViewDistance.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.game; import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; @@ -20,13 +20,13 @@ public class ViewDistance extends DefinedPacket @Override public void read(ByteBuf buf) { - distance = DefinedPacket.readVarInt( buf ); + distance = readVarInt( buf ); } @Override public void write(ByteBuf buf) { - DefinedPacket.writeVarInt( distance, buf ); + writeVarInt( distance, buf ); } @Override diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Handshake.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/handshake/Handshake.java similarity index 95% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/Handshake.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/handshake/Handshake.java index 7dbbfd3cd0..65bb91e194 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Handshake.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/handshake/Handshake.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.handshake; import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; 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/login/EncryptionRequest.java similarity index 75% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/EncryptionRequest.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/login/EncryptionRequest.java index a29524ca81..d09f0ad6f9 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/login/EncryptionRequest.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.login; import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; @@ -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/EncryptionResponse.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/login/EncryptionResponse.java similarity index 97% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/EncryptionResponse.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/login/EncryptionResponse.java index 63e9d18da2..eeacf5c204 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/EncryptionResponse.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/login/EncryptionResponse.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.login; import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginAcknowledged.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/login/LoginAcknowledged.java similarity index 94% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginAcknowledged.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/login/LoginAcknowledged.java index 1df2915d2d..1b63048572 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginAcknowledged.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/login/LoginAcknowledged.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.login; import io.netty.buffer.ByteBuf; import lombok.Data; diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginPayloadRequest.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/login/LoginPayloadRequest.java similarity index 96% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginPayloadRequest.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/login/LoginPayloadRequest.java index c468caef52..3ac7f19b10 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginPayloadRequest.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/login/LoginPayloadRequest.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.login; import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginPayloadResponse.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/login/LoginPayloadResponse.java similarity index 96% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginPayloadResponse.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/login/LoginPayloadResponse.java index fdccaeaf83..d7d21c495b 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginPayloadResponse.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/login/LoginPayloadResponse.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.login; import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginRequest.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/login/LoginRequest.java similarity index 97% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginRequest.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/login/LoginRequest.java index e62a3a03e9..aefa729b72 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginRequest.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/login/LoginRequest.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.login; import io.netty.buffer.ByteBuf; import java.util.UUID; @@ -21,7 +21,6 @@ public class LoginRequest extends DefinedPacket private String data; private PlayerPublicKey publicKey; private UUID uuid; - @Override public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) { diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginSuccess.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/login/LoginSuccess.java similarity index 97% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginSuccess.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/login/LoginSuccess.java index 07fb3d79a0..3b515bbb9e 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginSuccess.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/login/LoginSuccess.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.login; import io.netty.buffer.ByteBuf; import java.util.UUID; diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/SetCompression.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/login/SetCompression.java similarity index 85% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/SetCompression.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/login/SetCompression.java index 086e3e6edf..f4a7b6e07e 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/SetCompression.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/login/SetCompression.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.login; import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; @@ -21,13 +21,13 @@ public class SetCompression extends DefinedPacket @Override public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) { - threshold = DefinedPacket.readVarInt( buf ); + threshold = readVarInt( buf ); } @Override public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) { - DefinedPacket.writeVarInt( threshold, buf ); + writeVarInt( threshold, buf ); } @Override diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/PingPacket.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/status/PingPacket.java similarity index 93% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/PingPacket.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/status/PingPacket.java index 5f24d42592..7ebdf71579 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/PingPacket.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/status/PingPacket.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.status; import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/StatusRequest.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/status/StatusRequest.java similarity index 92% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/StatusRequest.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/status/StatusRequest.java index 738f0c92a6..23e335e90d 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/StatusRequest.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/status/StatusRequest.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.status; import io.netty.buffer.ByteBuf; import lombok.Data; diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/StatusResponse.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/status/StatusResponse.java similarity index 94% rename from protocol/src/main/java/net/md_5/bungee/protocol/packet/StatusResponse.java rename to protocol/src/main/java/net/md_5/bungee/protocol/packet/status/StatusResponse.java index 69a9d46cfe..7a0bf1196f 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/StatusResponse.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/status/StatusResponse.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.protocol.packet; +package net.md_5.bungee.protocol.packet.status; import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; diff --git a/protocol/src/test/java/net/md_5/bungee/protocol/packet/PluginMessageTest.java b/protocol/src/test/java/net/md_5/bungee/protocol/packet/PluginMessageTest.java index 5d52f30061..8b020b04e4 100644 --- a/protocol/src/test/java/net/md_5/bungee/protocol/packet/PluginMessageTest.java +++ b/protocol/src/test/java/net/md_5/bungee/protocol/packet/PluginMessageTest.java @@ -1,6 +1,7 @@ package net.md_5.bungee.protocol.packet; import static org.junit.jupiter.api.Assertions.*; +import net.md_5.bungee.protocol.packet.common.PluginMessage; import org.junit.jupiter.api.Test; public class PluginMessageTest diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java index e7f3f09af9..09ca33982f 100644 --- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java +++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java @@ -95,7 +95,7 @@ import net.md_5.bungee.netty.PipelineUtils; import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.ProtocolConstants; -import net.md_5.bungee.protocol.packet.PluginMessage; +import net.md_5.bungee.protocol.packet.common.PluginMessage; import net.md_5.bungee.query.RemoteQuery; import net.md_5.bungee.scheduler.BungeeScheduler; import net.md_5.bungee.util.CaseInsensitiveMap; diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeServerInfo.java b/proxy/src/main/java/net/md_5/bungee/BungeeServerInfo.java index 671cf96ff2..9dbfcd9c3c 100644 --- a/proxy/src/main/java/net/md_5/bungee/BungeeServerInfo.java +++ b/proxy/src/main/java/net/md_5/bungee/BungeeServerInfo.java @@ -29,7 +29,7 @@ import net.md_5.bungee.netty.HandlerBoss; import net.md_5.bungee.netty.PipelineUtils; import net.md_5.bungee.protocol.DefinedPacket; -import net.md_5.bungee.protocol.packet.PluginMessage; +import net.md_5.bungee.protocol.packet.common.PluginMessage; // CHECKSTYLE:OFF @RequiredArgsConstructor diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeTitle.java b/proxy/src/main/java/net/md_5/bungee/BungeeTitle.java index 9a6ef7a5fd..3751dfdf9a 100644 --- a/proxy/src/main/java/net/md_5/bungee/BungeeTitle.java +++ b/proxy/src/main/java/net/md_5/bungee/BungeeTitle.java @@ -7,15 +7,15 @@ import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.ProtocolConstants; -import net.md_5.bungee.protocol.packet.ClearTitles; -import net.md_5.bungee.protocol.packet.Subtitle; -import net.md_5.bungee.protocol.packet.Title.Action; -import net.md_5.bungee.protocol.packet.TitleTimes; +import net.md_5.bungee.protocol.packet.game.ClearTitles; +import net.md_5.bungee.protocol.packet.game.Subtitle; +import net.md_5.bungee.protocol.packet.game.Title.Action; +import net.md_5.bungee.protocol.packet.game.TitleTimes; public class BungeeTitle implements Title { - private TitlePacketHolder title; + private TitlePacketHolder title; private TitlePacketHolder subtitle; private TitlePacketHolder times; private TitlePacketHolder clear; @@ -25,13 +25,13 @@ public class BungeeTitle implements Title private static class TitlePacketHolder { - private final net.md_5.bungee.protocol.packet.Title oldPacket; + private final net.md_5.bungee.protocol.packet.game.Title oldPacket; private final T newPacket; } private static TitlePacketHolder createAnimationPacket() { - TitlePacketHolder title = new TitlePacketHolder<>( new net.md_5.bungee.protocol.packet.Title( Action.TIMES ), new TitleTimes() ); + TitlePacketHolder title = new TitlePacketHolder<>( new net.md_5.bungee.protocol.packet.game.Title( Action.TIMES ), new TitleTimes() ); title.oldPacket.setFadeIn( 20 ); title.oldPacket.setStay( 60 ); @@ -49,7 +49,7 @@ public Title title(BaseComponent text) { if ( title == null ) { - net.md_5.bungee.protocol.packet.Title packet = new net.md_5.bungee.protocol.packet.Title( Action.TITLE ); + net.md_5.bungee.protocol.packet.game.Title packet = new net.md_5.bungee.protocol.packet.game.Title( Action.TITLE ); title = new TitlePacketHolder<>( packet, packet ); } @@ -68,7 +68,7 @@ public Title subTitle(BaseComponent text) { if ( subtitle == null ) { - subtitle = new TitlePacketHolder<>( new net.md_5.bungee.protocol.packet.Title( Action.SUBTITLE ), new Subtitle() ); + subtitle = new TitlePacketHolder<>( new net.md_5.bungee.protocol.packet.game.Title( Action.SUBTITLE ), new Subtitle() ); } subtitle.oldPacket.setText( text ); @@ -126,7 +126,7 @@ public Title clear() { if ( clear == null ) { - clear = new TitlePacketHolder<>( new net.md_5.bungee.protocol.packet.Title( Action.CLEAR ), new ClearTitles() ); + clear = new TitlePacketHolder<>( new net.md_5.bungee.protocol.packet.game.Title( Action.CLEAR ), new ClearTitles() ); } title = null; // No need to send title if we clear it after that again @@ -139,7 +139,7 @@ public Title reset() { if ( reset == null ) { - reset = new TitlePacketHolder<>( new net.md_5.bungee.protocol.packet.Title( Action.RESET ), new ClearTitles( true ) ); + reset = new TitlePacketHolder<>( new net.md_5.bungee.protocol.packet.game.Title( Action.RESET ), new ClearTitles( true ) ); } // No need to send these packets if we reset them later 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..0b320bc750 100644 --- a/proxy/src/main/java/net/md_5/bungee/EncryptionUtil.java +++ b/proxy/src/main/java/net/md_5/bungee/EncryptionUtil.java @@ -29,8 +29,8 @@ import net.md_5.bungee.jni.cipher.JavaCipher; import net.md_5.bungee.jni.cipher.NativeCipher; import net.md_5.bungee.protocol.PlayerPublicKey; -import net.md_5.bungee.protocol.packet.EncryptionRequest; -import net.md_5.bungee.protocol.packet.EncryptionResponse; +import net.md_5.bungee.protocol.packet.login.EncryptionRequest; +import net.md_5.bungee.protocol.packet.login.EncryptionResponse; /** * Class containing all encryption related methods for the proxy. @@ -73,7 +73,7 @@ public static EncryptionRequest encryptRequest() byte[] pubKey = keys.getPublic().getEncoded(); byte[] verify = new byte[ 4 ]; random.nextBytes( verify ); - return new EncryptionRequest( hash, pubKey, verify ); + 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/ServerConnection.java b/proxy/src/main/java/net/md_5/bungee/ServerConnection.java index 5d54045027..cf7ba5ed03 100644 --- a/proxy/src/main/java/net/md_5/bungee/ServerConnection.java +++ b/proxy/src/main/java/net/md_5/bungee/ServerConnection.java @@ -15,7 +15,7 @@ import net.md_5.bungee.netty.ChannelWrapper; import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.Protocol; -import net.md_5.bungee.protocol.packet.PluginMessage; +import net.md_5.bungee.protocol.packet.common.PluginMessage; @RequiredArgsConstructor public class ServerConnection implements Server 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..bf65099fa6 100644 --- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java +++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java @@ -39,24 +39,25 @@ import net.md_5.bungee.protocol.PacketWrapper; import net.md_5.bungee.protocol.Protocol; import net.md_5.bungee.protocol.ProtocolConstants; -import net.md_5.bungee.protocol.packet.EncryptionRequest; -import net.md_5.bungee.protocol.packet.EntityStatus; -import net.md_5.bungee.protocol.packet.GameState; -import net.md_5.bungee.protocol.packet.Handshake; -import net.md_5.bungee.protocol.packet.Kick; -import net.md_5.bungee.protocol.packet.Login; -import net.md_5.bungee.protocol.packet.LoginPayloadRequest; -import net.md_5.bungee.protocol.packet.LoginPayloadResponse; -import net.md_5.bungee.protocol.packet.LoginRequest; -import net.md_5.bungee.protocol.packet.LoginSuccess; -import net.md_5.bungee.protocol.packet.PluginMessage; -import net.md_5.bungee.protocol.packet.Respawn; -import net.md_5.bungee.protocol.packet.ScoreboardObjective; -import net.md_5.bungee.protocol.packet.ScoreboardScore; -import net.md_5.bungee.protocol.packet.ScoreboardScoreReset; -import net.md_5.bungee.protocol.packet.SetCompression; -import net.md_5.bungee.protocol.packet.StartConfiguration; -import net.md_5.bungee.protocol.packet.ViewDistance; +import net.md_5.bungee.protocol.packet.common.Kick; +import net.md_5.bungee.protocol.packet.common.PluginMessage; +import net.md_5.bungee.protocol.packet.game.BossBar; +import net.md_5.bungee.protocol.packet.game.EntityStatus; +import net.md_5.bungee.protocol.packet.game.GameState; +import net.md_5.bungee.protocol.packet.game.Login; +import net.md_5.bungee.protocol.packet.game.Respawn; +import net.md_5.bungee.protocol.packet.game.ScoreboardObjective; +import net.md_5.bungee.protocol.packet.game.ScoreboardScore; +import net.md_5.bungee.protocol.packet.game.ScoreboardScoreReset; +import net.md_5.bungee.protocol.packet.game.StartConfiguration; +import net.md_5.bungee.protocol.packet.game.ViewDistance; +import net.md_5.bungee.protocol.packet.handshake.Handshake; +import net.md_5.bungee.protocol.packet.login.EncryptionRequest; +import net.md_5.bungee.protocol.packet.login.LoginPayloadRequest; +import net.md_5.bungee.protocol.packet.login.LoginPayloadResponse; +import net.md_5.bungee.protocol.packet.login.LoginRequest; +import net.md_5.bungee.protocol.packet.login.LoginSuccess; +import net.md_5.bungee.protocol.packet.login.SetCompression; import net.md_5.bungee.util.AddressUtil; import net.md_5.bungee.util.BufUtil; import net.md_5.bungee.util.QuietException; @@ -243,7 +244,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 ); @@ -256,7 +257,7 @@ public static void handleLogin(ProxyServer bungee, ChannelWrapper ch, UserConnec for ( UUID bossbar : user.getSentBossBars() ) { // Send remove bossbar packet - user.unsafe().sendPacket( new net.md_5.bungee.protocol.packet.BossBar( bossbar, 1 ) ); + user.unsafe().sendPacket( new BossBar( bossbar, 1 ) ); } user.getSentBossBars().clear(); @@ -300,14 +301,14 @@ public static void handleLogin(ProxyServer bungee, ChannelWrapper ch, UserConnec } for ( Team team : serverScoreboard.getTeams() ) { - user.unsafe().sendPacket( new net.md_5.bungee.protocol.packet.Team( team.getName() ) ); + user.unsafe().sendPacket( new net.md_5.bungee.protocol.packet.game.Team( team.getName() ) ); } serverScoreboard.clear(); for ( UUID bossbar : user.getSentBossBars() ) { // Send remove bossbar packet - user.unsafe().sendPacket( new net.md_5.bungee.protocol.packet.BossBar( bossbar, 1 ) ); + user.unsafe().sendPacket( new BossBar( bossbar, 1 ) ); } user.getSentBossBars().clear(); diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java b/proxy/src/main/java/net/md_5/bungee/UserConnection.java index 04143a4689..0837c5ef70 100644 --- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java +++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java @@ -54,13 +54,13 @@ import net.md_5.bungee.protocol.PacketWrapper; import net.md_5.bungee.protocol.Protocol; import net.md_5.bungee.protocol.ProtocolConstants; -import net.md_5.bungee.protocol.packet.Chat; -import net.md_5.bungee.protocol.packet.ClientSettings; -import net.md_5.bungee.protocol.packet.Kick; -import net.md_5.bungee.protocol.packet.PlayerListHeaderFooter; -import net.md_5.bungee.protocol.packet.PluginMessage; -import net.md_5.bungee.protocol.packet.SetCompression; -import net.md_5.bungee.protocol.packet.SystemChat; +import net.md_5.bungee.protocol.packet.common.ClientSettings; +import net.md_5.bungee.protocol.packet.common.Kick; +import net.md_5.bungee.protocol.packet.common.PluginMessage; +import net.md_5.bungee.protocol.packet.game.Chat; +import net.md_5.bungee.protocol.packet.game.PlayerListHeaderFooter; +import net.md_5.bungee.protocol.packet.game.SystemChat; +import net.md_5.bungee.protocol.packet.login.SetCompression; import net.md_5.bungee.tab.ServerUnique; import net.md_5.bungee.tab.TabList; import net.md_5.bungee.util.CaseInsensitiveSet; @@ -518,8 +518,8 @@ private void sendMessage(ChatMessageType position, UUID sender, BaseComponent me message = new TextComponent( BaseComponent.toLegacyText( message ) ); } else { - net.md_5.bungee.protocol.packet.Title title = new net.md_5.bungee.protocol.packet.Title(); - title.setAction( net.md_5.bungee.protocol.packet.Title.Action.ACTIONBAR ); + net.md_5.bungee.protocol.packet.game.Title title = new net.md_5.bungee.protocol.packet.game.Title(); + title.setAction( net.md_5.bungee.protocol.packet.game.Title.Action.ACTIONBAR ); title.setText( message ); sendPacketQueued( title ); return; diff --git a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java index 27737d1b43..5f8df74185 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java @@ -54,23 +54,23 @@ import net.md_5.bungee.protocol.PacketWrapper; import net.md_5.bungee.protocol.Protocol; import net.md_5.bungee.protocol.ProtocolConstants; -import net.md_5.bungee.protocol.packet.BossBar; -import net.md_5.bungee.protocol.packet.Commands; -import net.md_5.bungee.protocol.packet.KeepAlive; -import net.md_5.bungee.protocol.packet.Kick; -import net.md_5.bungee.protocol.packet.Login; -import net.md_5.bungee.protocol.packet.PlayerListItem; -import net.md_5.bungee.protocol.packet.PlayerListItemRemove; -import net.md_5.bungee.protocol.packet.PlayerListItemUpdate; -import net.md_5.bungee.protocol.packet.PluginMessage; -import net.md_5.bungee.protocol.packet.Respawn; -import net.md_5.bungee.protocol.packet.ScoreboardDisplay; -import net.md_5.bungee.protocol.packet.ScoreboardObjective; -import net.md_5.bungee.protocol.packet.ScoreboardScore; -import net.md_5.bungee.protocol.packet.ScoreboardScoreReset; -import net.md_5.bungee.protocol.packet.ServerData; -import net.md_5.bungee.protocol.packet.SetCompression; -import net.md_5.bungee.protocol.packet.TabCompleteResponse; +import net.md_5.bungee.protocol.packet.common.KeepAlive; +import net.md_5.bungee.protocol.packet.common.Kick; +import net.md_5.bungee.protocol.packet.common.PluginMessage; +import net.md_5.bungee.protocol.packet.game.BossBar; +import net.md_5.bungee.protocol.packet.game.Commands; +import net.md_5.bungee.protocol.packet.game.Login; +import net.md_5.bungee.protocol.packet.game.PlayerListItem; +import net.md_5.bungee.protocol.packet.game.PlayerListItemRemove; +import net.md_5.bungee.protocol.packet.game.PlayerListItemUpdate; +import net.md_5.bungee.protocol.packet.game.Respawn; +import net.md_5.bungee.protocol.packet.game.ScoreboardDisplay; +import net.md_5.bungee.protocol.packet.game.ScoreboardObjective; +import net.md_5.bungee.protocol.packet.game.ScoreboardScore; +import net.md_5.bungee.protocol.packet.game.ScoreboardScoreReset; +import net.md_5.bungee.protocol.packet.game.ServerData; +import net.md_5.bungee.protocol.packet.game.TabCompleteResponse; +import net.md_5.bungee.protocol.packet.login.SetCompression; import net.md_5.bungee.tab.TabList; @RequiredArgsConstructor @@ -242,7 +242,7 @@ public void handle(ScoreboardDisplay displayScoreboard) throws Exception } @Override - public void handle(net.md_5.bungee.protocol.packet.Team team) throws Exception + public void handle(net.md_5.bungee.protocol.packet.game.Team team) throws Exception { Scoreboard serverScoreboard = con.getServerSentScoreboard(); // Remove team and move on 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..7343498215 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 @@ -51,19 +51,19 @@ import net.md_5.bungee.protocol.PlayerPublicKey; import net.md_5.bungee.protocol.Protocol; import net.md_5.bungee.protocol.ProtocolConstants; -import net.md_5.bungee.protocol.packet.EncryptionRequest; -import net.md_5.bungee.protocol.packet.EncryptionResponse; -import net.md_5.bungee.protocol.packet.Handshake; -import net.md_5.bungee.protocol.packet.Kick; import net.md_5.bungee.protocol.packet.LegacyHandshake; import net.md_5.bungee.protocol.packet.LegacyPing; -import net.md_5.bungee.protocol.packet.LoginPayloadResponse; -import net.md_5.bungee.protocol.packet.LoginRequest; -import net.md_5.bungee.protocol.packet.LoginSuccess; -import net.md_5.bungee.protocol.packet.PingPacket; -import net.md_5.bungee.protocol.packet.PluginMessage; -import net.md_5.bungee.protocol.packet.StatusRequest; -import net.md_5.bungee.protocol.packet.StatusResponse; +import net.md_5.bungee.protocol.packet.common.Kick; +import net.md_5.bungee.protocol.packet.common.PluginMessage; +import net.md_5.bungee.protocol.packet.handshake.Handshake; +import net.md_5.bungee.protocol.packet.login.EncryptionRequest; +import net.md_5.bungee.protocol.packet.login.EncryptionResponse; +import net.md_5.bungee.protocol.packet.login.LoginPayloadResponse; +import net.md_5.bungee.protocol.packet.login.LoginRequest; +import net.md_5.bungee.protocol.packet.login.LoginSuccess; +import net.md_5.bungee.protocol.packet.status.PingPacket; +import net.md_5.bungee.protocol.packet.status.StatusRequest; +import net.md_5.bungee.protocol.packet.status.StatusResponse; import net.md_5.bungee.util.AllowedCharacters; import net.md_5.bungee.util.BufUtil; import net.md_5.bungee.util.QuietException; @@ -110,6 +110,7 @@ public void sendPacket(DefinedPacket packet) @Getter private String extraDataInHandshake = ""; private UserConnection userCon; + private boolean transferred; @Override public boolean shouldHandle(PacketWrapper packet) throws Exception @@ -349,6 +350,8 @@ public void handle(Handshake handshake) throws Exception ch.setProtocol( Protocol.STATUS ); break; case 2: + case 3: + 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/connection/PingHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/PingHandler.java index 6df3f3dd9f..8d6a452290 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/PingHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/PingHandler.java @@ -16,9 +16,9 @@ import net.md_5.bungee.protocol.MinecraftEncoder; import net.md_5.bungee.protocol.PacketWrapper; import net.md_5.bungee.protocol.Protocol; -import net.md_5.bungee.protocol.packet.Handshake; -import net.md_5.bungee.protocol.packet.StatusRequest; -import net.md_5.bungee.protocol.packet.StatusResponse; +import net.md_5.bungee.protocol.packet.handshake.Handshake; +import net.md_5.bungee.protocol.packet.status.StatusRequest; +import net.md_5.bungee.protocol.packet.status.StatusResponse; import net.md_5.bungee.util.BufUtil; import net.md_5.bungee.util.QuietException; diff --git a/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java index 460aa49159..4ae02cc874 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java @@ -28,19 +28,19 @@ import net.md_5.bungee.protocol.PacketWrapper; import net.md_5.bungee.protocol.Protocol; import net.md_5.bungee.protocol.ProtocolConstants; -import net.md_5.bungee.protocol.packet.Chat; -import net.md_5.bungee.protocol.packet.ClientChat; -import net.md_5.bungee.protocol.packet.ClientCommand; -import net.md_5.bungee.protocol.packet.ClientSettings; -import net.md_5.bungee.protocol.packet.FinishConfiguration; -import net.md_5.bungee.protocol.packet.KeepAlive; -import net.md_5.bungee.protocol.packet.LoginAcknowledged; -import net.md_5.bungee.protocol.packet.PlayerListItem; -import net.md_5.bungee.protocol.packet.PlayerListItemRemove; -import net.md_5.bungee.protocol.packet.PluginMessage; -import net.md_5.bungee.protocol.packet.StartConfiguration; -import net.md_5.bungee.protocol.packet.TabCompleteRequest; -import net.md_5.bungee.protocol.packet.TabCompleteResponse; +import net.md_5.bungee.protocol.packet.common.ClientSettings; +import net.md_5.bungee.protocol.packet.common.KeepAlive; +import net.md_5.bungee.protocol.packet.common.PluginMessage; +import net.md_5.bungee.protocol.packet.configuration.FinishConfiguration; +import net.md_5.bungee.protocol.packet.game.Chat; +import net.md_5.bungee.protocol.packet.game.ClientChat; +import net.md_5.bungee.protocol.packet.game.ClientCommand; +import net.md_5.bungee.protocol.packet.game.PlayerListItem; +import net.md_5.bungee.protocol.packet.game.PlayerListItemRemove; +import net.md_5.bungee.protocol.packet.game.StartConfiguration; +import net.md_5.bungee.protocol.packet.game.TabCompleteRequest; +import net.md_5.bungee.protocol.packet.game.TabCompleteResponse; +import net.md_5.bungee.protocol.packet.login.LoginAcknowledged; import net.md_5.bungee.util.AllowedCharacters; public class UpstreamBridge extends PacketHandler 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..7f7bf8f933 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,8 @@ 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; diff --git a/proxy/src/main/java/net/md_5/bungee/forge/ForgeClientHandler.java b/proxy/src/main/java/net/md_5/bungee/forge/ForgeClientHandler.java index d15044f40a..fd029126ba 100644 --- a/proxy/src/main/java/net/md_5/bungee/forge/ForgeClientHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/forge/ForgeClientHandler.java @@ -9,7 +9,7 @@ import lombok.RequiredArgsConstructor; import lombok.Setter; import net.md_5.bungee.UserConnection; -import net.md_5.bungee.protocol.packet.PluginMessage; +import net.md_5.bungee.protocol.packet.common.PluginMessage; /** * Handles the Forge Client data and handshake procedure. diff --git a/proxy/src/main/java/net/md_5/bungee/forge/ForgeClientHandshakeState.java b/proxy/src/main/java/net/md_5/bungee/forge/ForgeClientHandshakeState.java index 5242926540..20f141af6b 100644 --- a/proxy/src/main/java/net/md_5/bungee/forge/ForgeClientHandshakeState.java +++ b/proxy/src/main/java/net/md_5/bungee/forge/ForgeClientHandshakeState.java @@ -3,7 +3,7 @@ import java.util.Map; import net.md_5.bungee.ServerConnector; import net.md_5.bungee.UserConnection; -import net.md_5.bungee.protocol.packet.PluginMessage; +import net.md_5.bungee.protocol.packet.common.PluginMessage; /** * Handshake sequence manager for the Bungee - Forge Client (Upstream) link. diff --git a/proxy/src/main/java/net/md_5/bungee/forge/ForgeConstants.java b/proxy/src/main/java/net/md_5/bungee/forge/ForgeConstants.java index 6dca204830..a263e1afec 100644 --- a/proxy/src/main/java/net/md_5/bungee/forge/ForgeConstants.java +++ b/proxy/src/main/java/net/md_5/bungee/forge/ForgeConstants.java @@ -1,7 +1,7 @@ package net.md_5.bungee.forge; import java.util.regex.Pattern; -import net.md_5.bungee.protocol.packet.PluginMessage; +import net.md_5.bungee.protocol.packet.common.PluginMessage; public class ForgeConstants { diff --git a/proxy/src/main/java/net/md_5/bungee/forge/ForgeLogger.java b/proxy/src/main/java/net/md_5/bungee/forge/ForgeLogger.java index e1307f59fa..45b846977c 100644 --- a/proxy/src/main/java/net/md_5/bungee/forge/ForgeLogger.java +++ b/proxy/src/main/java/net/md_5/bungee/forge/ForgeLogger.java @@ -4,7 +4,7 @@ import lombok.AccessLevel; import lombok.NoArgsConstructor; import net.md_5.bungee.BungeeCord; -import net.md_5.bungee.protocol.packet.PluginMessage; +import net.md_5.bungee.protocol.packet.common.PluginMessage; @NoArgsConstructor(access = AccessLevel.PRIVATE) final class ForgeLogger diff --git a/proxy/src/main/java/net/md_5/bungee/forge/ForgeServerHandler.java b/proxy/src/main/java/net/md_5/bungee/forge/ForgeServerHandler.java index 77d18e6d8b..7142716d3e 100644 --- a/proxy/src/main/java/net/md_5/bungee/forge/ForgeServerHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/forge/ForgeServerHandler.java @@ -8,7 +8,7 @@ import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.forge.ForgeLogger.LogDirection; import net.md_5.bungee.netty.ChannelWrapper; -import net.md_5.bungee.protocol.packet.PluginMessage; +import net.md_5.bungee.protocol.packet.common.PluginMessage; /** * Contains data about the Forge server, and handles the handshake. diff --git a/proxy/src/main/java/net/md_5/bungee/forge/ForgeServerHandshakeState.java b/proxy/src/main/java/net/md_5/bungee/forge/ForgeServerHandshakeState.java index d58b4945fd..d9a3e40701 100644 --- a/proxy/src/main/java/net/md_5/bungee/forge/ForgeServerHandshakeState.java +++ b/proxy/src/main/java/net/md_5/bungee/forge/ForgeServerHandshakeState.java @@ -3,7 +3,7 @@ import net.md_5.bungee.UserConnection; import net.md_5.bungee.forge.ForgeLogger.LogDirection; import net.md_5.bungee.netty.ChannelWrapper; -import net.md_5.bungee.protocol.packet.PluginMessage; +import net.md_5.bungee.protocol.packet.common.PluginMessage; /** * Handshake sequence manager for the Bungee - Forge Server (Downstream/Server diff --git a/proxy/src/main/java/net/md_5/bungee/forge/ForgeUtils.java b/proxy/src/main/java/net/md_5/bungee/forge/ForgeUtils.java index 0def5be6ba..0cb9a4d04d 100644 --- a/proxy/src/main/java/net/md_5/bungee/forge/ForgeUtils.java +++ b/proxy/src/main/java/net/md_5/bungee/forge/ForgeUtils.java @@ -9,7 +9,7 @@ import java.util.Set; import java.util.regex.Matcher; import net.md_5.bungee.protocol.DefinedPacket; -import net.md_5.bungee.protocol.packet.PluginMessage; +import net.md_5.bungee.protocol.packet.common.PluginMessage; public class ForgeUtils { diff --git a/proxy/src/main/java/net/md_5/bungee/forge/IForgeClientPacketHandler.java b/proxy/src/main/java/net/md_5/bungee/forge/IForgeClientPacketHandler.java index ccdbe1bc09..73626e1185 100644 --- a/proxy/src/main/java/net/md_5/bungee/forge/IForgeClientPacketHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/forge/IForgeClientPacketHandler.java @@ -1,7 +1,7 @@ package net.md_5.bungee.forge; import net.md_5.bungee.UserConnection; -import net.md_5.bungee.protocol.packet.PluginMessage; +import net.md_5.bungee.protocol.packet.common.PluginMessage; /** * An interface that defines a Forge Handshake Client packet. diff --git a/proxy/src/main/java/net/md_5/bungee/forge/IForgeServerPacketHandler.java b/proxy/src/main/java/net/md_5/bungee/forge/IForgeServerPacketHandler.java index 6699a47c57..993bc12978 100644 --- a/proxy/src/main/java/net/md_5/bungee/forge/IForgeServerPacketHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/forge/IForgeServerPacketHandler.java @@ -2,7 +2,7 @@ import net.md_5.bungee.UserConnection; import net.md_5.bungee.netty.ChannelWrapper; -import net.md_5.bungee.protocol.packet.PluginMessage; +import net.md_5.bungee.protocol.packet.common.PluginMessage; /** * An interface that defines a Forge Handshake Server packet. @@ -13,10 +13,10 @@ public interface IForgeServerPacketHandler { /** - * Handles any {@link net.md_5.bungee.protocol.packet.PluginMessage} + * Handles any {@link PluginMessage} * packets. * - * @param message The {@link net.md_5.bungee.protocol.packet.PluginMessage} + * @param message The {@link PluginMessage} * to handle. * @param ch The {@link ChannelWrapper} to send packets to. * @return The state to transition to. @@ -24,9 +24,9 @@ public interface IForgeServerPacketHandler public S handle(PluginMessage message, ChannelWrapper ch); /** - * Sends any {@link net.md_5.bungee.protocol.packet.PluginMessage} packets. + * Sends any {@link PluginMessage} packets. * - * @param message The {@link net.md_5.bungee.protocol.packet.PluginMessage} + * @param message The {@link PluginMessage} * to send. * @param con The {@link net.md_5.bungee.UserConnection} to send packets to * or read from. diff --git a/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java b/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java index e8d5ed1969..674c8a7629 100644 --- a/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java +++ b/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java @@ -16,7 +16,7 @@ import net.md_5.bungee.protocol.MinecraftEncoder; import net.md_5.bungee.protocol.PacketWrapper; import net.md_5.bungee.protocol.Protocol; -import net.md_5.bungee.protocol.packet.Kick; +import net.md_5.bungee.protocol.packet.common.Kick; public class ChannelWrapper { diff --git a/proxy/src/main/java/net/md_5/bungee/tab/ServerUnique.java b/proxy/src/main/java/net/md_5/bungee/tab/ServerUnique.java index f70d357a35..d76fb994e5 100644 --- a/proxy/src/main/java/net/md_5/bungee/tab/ServerUnique.java +++ b/proxy/src/main/java/net/md_5/bungee/tab/ServerUnique.java @@ -5,9 +5,9 @@ import java.util.UUID; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.protocol.ProtocolConstants; -import net.md_5.bungee.protocol.packet.PlayerListItem; -import net.md_5.bungee.protocol.packet.PlayerListItemRemove; -import net.md_5.bungee.protocol.packet.PlayerListItemUpdate; +import net.md_5.bungee.protocol.packet.game.PlayerListItem; +import net.md_5.bungee.protocol.packet.game.PlayerListItemRemove; +import net.md_5.bungee.protocol.packet.game.PlayerListItemUpdate; public class ServerUnique extends TabList { diff --git a/proxy/src/main/java/net/md_5/bungee/tab/TabList.java b/proxy/src/main/java/net/md_5/bungee/tab/TabList.java index a0baa38844..744522cadb 100644 --- a/proxy/src/main/java/net/md_5/bungee/tab/TabList.java +++ b/proxy/src/main/java/net/md_5/bungee/tab/TabList.java @@ -6,9 +6,9 @@ import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.connection.LoginResult; import net.md_5.bungee.protocol.Property; -import net.md_5.bungee.protocol.packet.PlayerListItem; -import net.md_5.bungee.protocol.packet.PlayerListItemRemove; -import net.md_5.bungee.protocol.packet.PlayerListItemUpdate; +import net.md_5.bungee.protocol.packet.game.PlayerListItem; +import net.md_5.bungee.protocol.packet.game.PlayerListItemRemove; +import net.md_5.bungee.protocol.packet.game.PlayerListItemUpdate; @RequiredArgsConstructor public abstract class TabList