Skip to content

Commit

Permalink
Complete LoginStartPacket with 1.19.1 changes
Browse files Browse the repository at this point in the history
Signed-off-by: TheMode <themode@outlook.fr>
  • Loading branch information
TheMode committed Jul 2, 2022
1 parent e8d79f4 commit 08a4216
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,25 @@
import net.minestom.server.utils.binary.BinaryReader;
import net.minestom.server.utils.binary.BinaryWriter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;

public record LoginStartPacket(@NotNull String username, PlayerPublicKey publicKey) implements ClientPreplayPacket {
public record LoginStartPacket(@NotNull String username,
@Nullable PlayerPublicKey publicKey,
@Nullable UUID profileId) implements ClientPreplayPacket {
private static final Component ALREADY_CONNECTED = Component.text("You are already on this server", NamedTextColor.RED);

public LoginStartPacket(BinaryReader reader) {
this(reader.readSizedString(16), reader.readBoolean() ? new PlayerPublicKey(reader) : null);
this(reader.readSizedString(16),
reader.readBoolean() ? new PlayerPublicKey(reader) : null,
reader.readBoolean() ? reader.readUuid() : null);
}

@Override
public void process(@NotNull PlayerConnection connection) {
// TODO use public key
// TODO use public key & uuid
final boolean isSocketConnection = connection instanceof PlayerSocketConnection;
// Proxy support (only for socket clients) and cache the login username
if (isSocketConnection) {
Expand Down

0 comments on commit 08a4216

Please sign in to comment.