mirror of
https://github.com/WorldEditAxe/eaglerproxy.git
synced 2024-11-14 09:36:04 -08:00
26 lines
860 B
JavaScript
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;
|
||
|
}
|
||
|
}
|