This commit is contained in:
Camotoy 2022-07-24 17:58:10 -04:00
parent e0960c0879
commit 1bfe9facb8
No known key found for this signature in database
GPG key ID: 7EEFB66FE798081F
4 changed files with 17 additions and 9 deletions

View file

@ -125,7 +125,7 @@ public class ClientListener extends SessionAdapter {
if (this.targetState == ProtocolState.LOGIN) { if (this.targetState == ProtocolState.LOGIN) {
GameProfile profile = session.getFlag(MinecraftConstants.PROFILE_KEY); 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 { } else {
session.send(new ServerboundStatusRequestPacket()); session.send(new ServerboundStatusRequestPacket());
} }

View file

@ -17,19 +17,16 @@ import java.io.IOException;
@AllArgsConstructor @AllArgsConstructor
public class ClientboundSystemChatPacket implements MinecraftPacket { public class ClientboundSystemChatPacket implements MinecraftPacket {
private final Component content; private final Component content;
/** private final boolean overlay;
* Is {@link BuiltinChatType} defined in the order sent by the server in the login packet.
*/
private final int typeId;
public ClientboundSystemChatPacket(ByteBuf in, MinecraftCodecHelper helper) { public ClientboundSystemChatPacket(ByteBuf in, MinecraftCodecHelper helper) {
this.content = helper.readComponent(in); this.content = helper.readComponent(in);
this.typeId = helper.readVarInt(in); this.overlay = in.readBoolean();
} }
@Override @Override
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
helper.writeString(out, DefaultComponentSerializer.get().serialize(this.content)); helper.writeString(out, DefaultComponentSerializer.get().serialize(this.content));
helper.writeVarInt(out, this.typeId); out.writeBoolean(this.overlay);
} }
} }

View file

@ -14,6 +14,7 @@ import java.security.GeneralSecurityException;
import java.security.KeyFactory; import java.security.KeyFactory;
import java.security.PublicKey; import java.security.PublicKey;
import java.security.spec.X509EncodedKeySpec; import java.security.spec.X509EncodedKeySpec;
import java.util.UUID;
@Data @Data
@With @With
@ -22,7 +23,8 @@ public class ServerboundHelloPacket implements MinecraftPacket {
private final @NonNull String username; private final @NonNull String username;
private final @Nullable Long expiresAt; private final @Nullable Long expiresAt;
private final @Nullable PublicKey publicKey; 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 { public ServerboundHelloPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
this.username = helper.readString(in); this.username = helper.readString(in);
@ -41,6 +43,11 @@ public class ServerboundHelloPacket implements MinecraftPacket {
this.publicKey = null; this.publicKey = null;
this.keySignature = null; this.keySignature = null;
} }
if (in.readBoolean()) {
this.profileId = helper.readUUID(in);
} else {
this.profileId = null;
}
} }
@Override @Override
@ -53,6 +60,10 @@ public class ServerboundHelloPacket implements MinecraftPacket {
helper.writeByteArray(out, encoded); helper.writeByteArray(out, encoded);
helper.writeByteArray(out, this.keySignature); helper.writeByteArray(out, this.keySignature);
} }
out.writeBoolean(this.profileId != null);
if (this.profileId != null) {
helper.writeUUID(out, this.profileId);
}
} }
@Override @Override

View file

@ -6,6 +6,6 @@ import org.junit.Before;
public class ServerboundHelloPacketTest extends PacketTest { public class ServerboundHelloPacketTest extends PacketTest {
@Before @Before
public void setup() { public void setup() {
this.setPackets(new ServerboundHelloPacket("Username", null, null, null)); this.setPackets(new ServerboundHelloPacket("Username", null, null, null, null));
} }
} }