From 1bfe9facb8e62cb02831bb52e809ef2eadbd49b1 Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Sun, 24 Jul 2022 17:58:10 -0400 Subject: [PATCH] Changes --- .../steveice10/mc/protocol/ClientListener.java | 2 +- .../clientbound/ClientboundSystemChatPacket.java | 9 +++------ .../login/serverbound/ServerboundHelloPacket.java | 13 ++++++++++++- .../serverbound/ServerboundHelloPacketTest.java | 2 +- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/github/steveice10/mc/protocol/ClientListener.java b/src/main/java/com/github/steveice10/mc/protocol/ClientListener.java index 6fd082c3..c74dd870 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/ClientListener.java +++ b/src/main/java/com/github/steveice10/mc/protocol/ClientListener.java @@ -125,7 +125,7 @@ public class ClientListener extends SessionAdapter { if (this.targetState == ProtocolState.LOGIN) { GameProfile profile = session.getFlag(MinecraftConstants.PROFILE_KEY); - session.send(new ServerboundHelloPacket(profile.getName(), null, null, null)); + session.send(new ServerboundHelloPacket(profile.getName(), null, null, null, profile.getId())); } else { session.send(new ServerboundStatusRequestPacket()); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundSystemChatPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundSystemChatPacket.java index 32fdc70d..7290ddaa 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundSystemChatPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundSystemChatPacket.java @@ -17,19 +17,16 @@ import java.io.IOException; @AllArgsConstructor public class ClientboundSystemChatPacket implements MinecraftPacket { private final Component content; - /** - * Is {@link BuiltinChatType} defined in the order sent by the server in the login packet. - */ - private final int typeId; + private final boolean overlay; public ClientboundSystemChatPacket(ByteBuf in, MinecraftCodecHelper helper) { this.content = helper.readComponent(in); - this.typeId = helper.readVarInt(in); + this.overlay = in.readBoolean(); } @Override public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { helper.writeString(out, DefaultComponentSerializer.get().serialize(this.content)); - helper.writeVarInt(out, this.typeId); + out.writeBoolean(this.overlay); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundHelloPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundHelloPacket.java index d902a2ec..53e01db7 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundHelloPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundHelloPacket.java @@ -14,6 +14,7 @@ import java.security.GeneralSecurityException; import java.security.KeyFactory; import java.security.PublicKey; import java.security.spec.X509EncodedKeySpec; +import java.util.UUID; @Data @With @@ -22,7 +23,8 @@ public class ServerboundHelloPacket implements MinecraftPacket { private final @NonNull String username; private final @Nullable Long expiresAt; private final @Nullable PublicKey publicKey; - private final @Nullable byte[] keySignature; + private final byte @Nullable[] keySignature; + private final @Nullable UUID profileId; public ServerboundHelloPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { this.username = helper.readString(in); @@ -41,6 +43,11 @@ public class ServerboundHelloPacket implements MinecraftPacket { this.publicKey = null; this.keySignature = null; } + if (in.readBoolean()) { + this.profileId = helper.readUUID(in); + } else { + this.profileId = null; + } } @Override @@ -53,6 +60,10 @@ public class ServerboundHelloPacket implements MinecraftPacket { helper.writeByteArray(out, encoded); helper.writeByteArray(out, this.keySignature); } + out.writeBoolean(this.profileId != null); + if (this.profileId != null) { + helper.writeUUID(out, this.profileId); + } } @Override diff --git a/src/test/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundHelloPacketTest.java b/src/test/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundHelloPacketTest.java index 83838001..ec7de684 100644 --- a/src/test/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundHelloPacketTest.java +++ b/src/test/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundHelloPacketTest.java @@ -6,6 +6,6 @@ import org.junit.Before; public class ServerboundHelloPacketTest extends PacketTest { @Before public void setup() { - this.setPackets(new ServerboundHelloPacket("Username", null, null, null)); + this.setPackets(new ServerboundHelloPacket("Username", null, null, null, null)); } }