mc-beta-server/server/packets/Chat.ts

26 lines
613 B
TypeScript
Raw Normal View History

2023-04-08 20:52:47 +01:00
import { Reader, Writer } from "../../bufferStuff";
import { Packets } from "../enums/Packets";
import { IPacket } from "./IPacket";
export class PacketChat implements IPacket {
public packetId = Packets.Chat;
public message:string;
2023-04-09 04:19:10 +01:00
public constructor(message?:string) {
if (typeof(message) === "string") {
this.message = message;
} else {
this.message = "";
}
2023-04-08 20:52:47 +01:00
}
public readData(reader:Reader) {
this.message = reader.readString();
return this;
}
public writeData() {
return new Writer(3 + this.message.length * 2).writeUByte(this.packetId).writeString(this.message).toBuffer();
}
}