-
Notifications
You must be signed in to change notification settings - Fork 58
/
client_login_success.go
42 lines (38 loc) · 1.08 KB
/
client_login_success.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
package v116
import (
"github.com/LilyPad/GoLilyPad/packet"
minecraft "github.com/LilyPad/GoLilyPad/packet/minecraft"
uuidlib "github.com/satori/go.uuid"
"io"
)
type CodecClientLoginSuccess struct {
IdMap *minecraft.IdMap
}
func (this *CodecClientLoginSuccess) Decode(reader io.Reader) (decode packet.Packet, err error) {
packetClientLoginSuccess := new(minecraft.PacketClientLoginSuccess)
packetClientLoginSuccess.IdFrom(this.IdMap)
uuid, err := packet.ReadUUID(reader)
if err != nil {
return
}
packetClientLoginSuccess.UUID = uuid.String()
packetClientLoginSuccess.Name, err = packet.ReadString(reader)
if err != nil {
return
}
decode = packetClientLoginSuccess
return
}
func (this *CodecClientLoginSuccess) Encode(writer io.Writer, encode packet.Packet) (err error) {
packetClientLoginSuccess := encode.(*minecraft.PacketClientLoginSuccess)
uuid, err := uuidlib.FromString(packetClientLoginSuccess.UUID)
if err != nil {
return
}
err = packet.WriteUUID(writer, uuid)
if err != nil {
return
}
err = packet.WriteString(writer, packetClientLoginSuccess.Name)
return
}