Add chat session

This commit is contained in:
Tnze
2023-01-01 13:17:07 +08:00
parent 77857a1a85
commit fa83b762bf
15 changed files with 244 additions and 25 deletions

View File

@ -2,12 +2,12 @@ package playerlist
import (
"bytes"
"errors"
"github.com/google/uuid"
"github.com/Tnze/go-mc/bot"
"github.com/Tnze/go-mc/chat"
"github.com/Tnze/go-mc/chat/sign"
"github.com/Tnze/go-mc/data/packetid"
pk "github.com/Tnze/go-mc/net/packet"
"github.com/Tnze/go-mc/yggdrasil/user"
@ -74,7 +74,11 @@ func (pl *PlayerList) handlePlayerInfoUpdatePacket(p pk.Packet) error {
}
// initialize chat
if action.Get(1) {
return errors.New("unsupported initialize chat yet")
var chatSession pk.Option[sign.Session, *sign.Session]
if _, err := chatSession.ReadFrom(r); err != nil {
return err
}
player.ChatSession = chatSession.Pointer()
}
// update gamemode
if action.Get(2) {
@ -123,7 +127,7 @@ func (pl *PlayerList) handlePlayerInfoRemovePacket(p pk.Packet) error {
type PlayerInfo struct {
GameProfile
// chatSession
ChatSession *sign.Session
Gamemode int32
Latency int32
Listed bool