Use packet queue for bot framework.

Providing concurrently-safing for sending packets.
This commit is contained in:
Tnze
2023-03-05 10:19:18 +08:00
parent 90501f1357
commit 925b1359fc
5 changed files with 85 additions and 14 deletions

View File

@ -51,7 +51,7 @@ func (p *Player) Respawn() error {
const PerformRespawn = 0
err := p.c.Conn.WritePacket(pk.Marshal(
int32(packetid.ServerboundClientCommand),
packetid.ServerboundClientCommand,
pk.VarInt(PerformRespawn),
))
if err != nil {

View File

@ -54,7 +54,7 @@ func (p *Player) handleLoginPacket(packet pk.Packet) error {
return Error{err}
}
err = p.c.Conn.WritePacket(pk.Marshal( // PluginMessage packet
int32(packetid.ServerboundCustomPayload),
packetid.ServerboundCustomPayload,
pk.Identifier("minecraft:brand"),
pk.String(p.Settings.Brand),
))
@ -63,7 +63,7 @@ func (p *Player) handleLoginPacket(packet pk.Packet) error {
}
err = p.c.Conn.WritePacket(pk.Marshal(
int32(packetid.ServerboundClientInformation), // Client settings
packetid.ServerboundClientInformation, // Client settings
pk.String(p.Settings.Locale),
pk.Byte(p.Settings.ViewDistance),
pk.VarInt(p.Settings.ChatMode),