Add playerinfo recorder for chat message
This commit is contained in:
@ -15,11 +15,13 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
"github.com/Tnze/go-mc/data/packetid"
|
||||
"github.com/Tnze/go-mc/net"
|
||||
"github.com/Tnze/go-mc/net/CFB8"
|
||||
pk "github.com/Tnze/go-mc/net/packet"
|
||||
"github.com/google/uuid"
|
||||
"github.com/Tnze/go-mc/yggdrasil/user"
|
||||
)
|
||||
|
||||
const verifyTokenLen = 16
|
||||
@ -171,42 +173,20 @@ func twosComplement(p []byte) []byte {
|
||||
return p
|
||||
}
|
||||
|
||||
type (
|
||||
Texture = user.Texture
|
||||
Property = user.Property
|
||||
)
|
||||
|
||||
// Resp is the response of authentication
|
||||
type Resp struct {
|
||||
Name string
|
||||
ID uuid.UUID
|
||||
Properties []Property
|
||||
}
|
||||
|
||||
type Property struct {
|
||||
Name, Value, Signature string
|
||||
}
|
||||
|
||||
func (p Property) WriteTo(w io.Writer) (n int64, err error) {
|
||||
return pk.Tuple{
|
||||
pk.String(p.Name),
|
||||
pk.String(p.Value),
|
||||
pk.Option[pk.String, *pk.String]{
|
||||
Has: p.Signature != "",
|
||||
Val: pk.String(p.Signature),
|
||||
},
|
||||
}.WriteTo(w)
|
||||
}
|
||||
|
||||
// Texture includes player's skin and cape
|
||||
type Texture struct {
|
||||
TimeStamp int64 `json:"timestamp"`
|
||||
ID uuid.UUID `json:"profileId"`
|
||||
Name string `json:"profileName"`
|
||||
Textures struct {
|
||||
SKIN, CAPE struct {
|
||||
URL string `json:"url"`
|
||||
}
|
||||
} `json:"textures"`
|
||||
Properties []user.Property
|
||||
}
|
||||
|
||||
// Texture unmarshal the base64 encoded texture of Resp
|
||||
func (r *Resp) Texture() (t Texture, err error) {
|
||||
func (r *Resp) Texture() (t user.Texture, err error) {
|
||||
var texture []byte
|
||||
texture, err = base64.StdEncoding.DecodeString(r.Properties[0].Value)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user