realms support

This commit is contained in:
Tnze
2019-08-09 23:50:53 +08:00
parent b0e6a70e0a
commit ad5dfeffd7
7 changed files with 316 additions and 1 deletions

36
realms/mco.go Normal file
View File

@ -0,0 +1,36 @@
package realms
import "io/ioutil"
// 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 := ioutil.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
}