realms

package
v1.20.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2023 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var Domain = "https://pc.realms.minecraft.net"

Domain is the URL of Realms API server Panic if it cannot be parsed by url.Parse().

Functions

This section is empty.

Types

type Error

type Error struct {
	ErrorCode int
	ErrorMsg  string
}

func (*Error) Error

func (e *Error) Error() string

type Realms

type Realms struct {
	// contains filtered or unexported fields
}
Example
var r *Realms

r = New(
	"1.14.4",
	"Name",
	"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
	"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
)
fmt.Println(r.Available())
fmt.Println(r.Compatible())

servers, err := r.Worlds()
if err != nil {
	panic(err)
}

for _, v := range servers {
	fmt.Println(v.Name, v.ID)
}

time.Sleep(time.Second * 5)
if err := r.TOS(); err != nil {
	panic(err)
}

time.Sleep(time.Second * 5)
fmt.Println(r.Address(servers[0]))
Output:

func New

func New(version, user, astk, uuid string) *Realms

New create a new Realms c with version, username, accessToken and UUID without dashes.

func (*Realms) Address

func (r *Realms) Address(s Server) (string, error)

Address used to get the IP address for a server. Call TOS before you call this function.

func (*Realms) Available

func (r *Realms) Available() (ok bool, err error)

Available returns whether the user can access the Minecraft Realms service

func (*Realms) Backups

func (r *Realms) Backups(s Server) ([]int, error)

Backups returns a list of backups for the world.

func (*Realms) Compatible

func (r *Realms) Compatible() (string, error)

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 (*Realms) Invite

func (r *Realms) Invite(s Server, name, uuid string) error

Invite player to Realm

func (*Realms) Ops

func (r *Realms) Ops(s Server) (ops []string, err error)

Ops returns a list of operators for this server. You must own this server to view this.

func (*Realms) Server

func (r *Realms) Server(ID int) (s Server, err error)

Server returns a single server listing about a server. you must be the owner of the server.

func (*Realms) SubscriptionLife

func (r *Realms) SubscriptionLife(s Server) (startDate int64, daysLeft int, Type string, err error)

SubscriptionLife returns the current life of a server subscription.

func (*Realms) TOS

func (r *Realms) TOS() error

TOS is what to join Realms servers you must agree to. Call this function will set this flag.

func (*Realms) Worlds

func (r *Realms) Worlds() ([]Server, error)

Worlds return a list of servers that the user is invited to or owns.

type Server

type Server struct {
	ID                   int
	RemoteSubscriptionID string
	Owner                string
	OwnerUUID            string
	Name                 string
	MOTD                 string
	State                string
	DaysLeft             int
	Expired              bool
	ExpiredTrial         bool
	WorldType            string
	Players              []string
	MaxPlayers           int
	MiniGameName         *string
	MiniGameID           *int
	MinigameImage        *string
	ActiveSlot           int
	// Slots                any
	Member bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL