/
purchase_receipt.go
39 lines (33 loc) · 973 Bytes
/
purchase_receipt.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
package packet
import (
"github.com/sandertv/gophertunnel/minecraft/protocol"
)
// PurchaseReceipt is sent by the client to the server to notify the server it purchased an item from the
// Marketplace store that was offered by the server. The packet is only used for partnered servers.
type PurchaseReceipt struct {
// Receipts is a list of receipts, or proofs of purchases, for the offers that have been purchased by the
// player.
Receipts []string
}
// ID ...
func (*PurchaseReceipt) ID() uint32 {
return IDPurchaseReceipt
}
// Marshal ...
func (pk *PurchaseReceipt) Marshal(w *protocol.Writer) {
l := uint32(len(pk.Receipts))
w.Varuint32(&l)
for _, receipt := range pk.Receipts {
w.String(&receipt)
}
}
// Unmarshal ...
func (pk *PurchaseReceipt) Unmarshal(r *protocol.Reader) {
var count uint32
r.Varuint32(&count)
r.LimitUint32(count, 64)
pk.Receipts = make([]string, count)
for i := uint32(0); i < count; i++ {
r.String(&pk.Receipts[i])
}
}