q13x-eaglerproxy/proxy/packets/SCSyncUuidPacket.js
idklol725 a52b7d834c ....
2024-09-04 12:04:47 +00:00

26 lines
860 B
JavaScript

import { Enums } from "../Enums.js";
import { MineProtocol } from "../Protocol.js";
import { Util } from "../Util.js";
export class SCSyncUuidPacket {
packetId = Enums.PacketId.SCSyncUuidPacket;
type = "packet";
boundTo = Enums.PacketBounds.C;
sentAfterHandshake = false;
username;
uuid;
serialize() {
return Buffer.concat([
[this.packetId],
MineProtocol.writeString(this.username),
Util.uuidStringToBuffer(this.uuid),
].map((arr) => (arr instanceof Uint8Array ? arr : Buffer.from(arr))));
}
deserialize(packet) {
packet = packet.subarray(1);
const username = MineProtocol.readString(packet), uuid = username.newBuffer.subarray(0, 15);
this.username = username.value;
this.uuid = Util.uuidBufferToString(uuid);
return this;
}
}