forked from Tnze/go-mc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mco.go
37 lines (31 loc) · 932 Bytes
/
mco.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
package realms
import "io"
// Available returns whether the user can access the Minecraft Realms service
func (r *Realms) Available() (ok bool, err error) {
err = r.get("/mco/available", &ok)
return
}
// Compatible returns whether the clients version is up-to-date with Realms.
//
// if the client is outdated, it returns OUTDATED,
// if the client is running a snapshot, it returns OTHER,
// else it returns COMPATIBLE.
func (r *Realms) Compatible() (string, error) {
resp, err := r.c.Get(Domain + "/mco/client/compatible")
if err != nil {
return "", err
}
defer resp.Body.Close()
rp, err := io.ReadAll(resp.Body)
return string(rp), err
}
// TOS is what to join Realms servers you must agree to.
// Call this function will set this flag.
func (r *Realms) TOS() error {
resp, err := r.c.Post(Domain+"/mco/tos/agreed", "application/json", nil)
if err != nil {
return err
}
defer resp.Body.Close()
return nil
}