/
property.go
47 lines (40 loc) · 939 Bytes
/
property.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package user
import (
"io"
"github.com/google/uuid"
pk "github.com/Tnze/go-mc/net/packet"
)
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)
}
func (p *Property) ReadFrom(r io.Reader) (n int64, err error) {
var signature pk.Option[pk.String, *pk.String]
n, err = pk.Tuple{
(*pk.String)(&p.Name),
(*pk.String)(&p.Value),
&signature,
}.ReadFrom(r)
p.Signature = string(signature.Val)
return
}
// 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"`
}