Skip to content

Commit

Permalink
🐛 Add a field in login success packet for 1.20.5
Browse files Browse the repository at this point in the history
  • Loading branch information
YvanMazy committed Apr 23, 2024
1 parent 53f1113 commit 7e98d18
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void sendLoginSuccess(final @NotNull UUID uuid, final @NotNull String use
this.ensureState(ConnectionState.LOGIN, "sendLoginSuccess");
Objects.requireNonNull(uuid, "uuid must not be null");
Objects.requireNonNull(username, "username must not be null");
this.sendPacket(new LoginSuccessPacket(uuid, username, null));
this.sendPacket(new LoginSuccessPacket(uuid, username, null, true));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,16 @@

import static be.darkkraft.transferproxy.util.BufUtil.*;

public record LoginSuccessPacket(UUID uuid, String username, Property[] properties) implements Packet {
public record LoginSuccessPacket(UUID uuid, String username, Property[] properties, boolean strictErrorHandling) implements Packet {

public LoginSuccessPacket(final @NotNull ByteBuf buf) {
this(readUUID(buf),
readString(buf, 16),
readArray(buf,
Property[]::new,
sub -> new Property(readString(sub), readString(sub), sub.readBoolean() ? readString(buf) : null),
16));
16),
buf.readBoolean());
}

@Override
Expand All @@ -52,19 +53,20 @@ public void write(final @NotNull ByteBuf buf) {
writeString(buf, this.username, 16);
if (this.properties == null) {
writeVarInt(buf, 0);
return;
} else {
writeArray(buf, this.properties, (sub, property) -> {
writeString(sub, property.name());
writeString(sub, property.value());
final String signature = property.signature();
if (signature != null && !signature.isEmpty()) {
sub.writeBoolean(true);
writeString(sub, signature);
} else {
sub.writeBoolean(false);
}
});
}
writeArray(buf, this.properties, (sub, property) -> {
writeString(sub, property.name());
writeString(sub, property.value());
final String signature = property.signature();
if (signature != null && !signature.isEmpty()) {
sub.writeBoolean(true);
writeString(sub, signature);
} else {
sub.writeBoolean(false);
}
});
buf.writeBoolean(this.strictErrorHandling);
}

@Override
Expand Down

0 comments on commit 7e98d18

Please sign in to comment.