q13x-eaglerproxy/server/proxy/packets/channel/SCChannelMessage.js

22 lines
774 B
JavaScript
Raw Normal View History

2024-09-04 05:02:00 -07:00
import { Enums } from "../../Enums.js";
import { MineProtocol } from "../../Protocol.js";
export class SCChannelMessagePacket {
packetId = Enums.PacketId.SCChannelMessagePacket;
type = "packet";
boundTo = Enums.PacketBounds.C;
sentAfterHandshake = true;
messageType = Enums.ChannelMessageType.SERVER;
channel;
data;
serialize() {
return Buffer.concat([[this.packetId], MineProtocol.writeString(this.channel), this.data].map((arr) => (arr instanceof Uint8Array ? arr : Buffer.from(arr))));
}
deserialize(packet) {
packet = packet.subarray(1);
const channel = MineProtocol.readString(packet), data = channel.newBuffer;
this.channel = channel.value;
this.data = data;
return this;
}
}