mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-11-14 19:34:58 -05:00
Changes
This commit is contained in:
parent
e0960c0879
commit
1bfe9facb8
4 changed files with 17 additions and 9 deletions
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue