q13x-eaglerproxy/server/proxy/packets/SCSyncUuidPacket.js

26 lines
860 B
JavaScript
Raw Normal View History

2024-09-04 05:02:00 -07:00
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;
}
}