minecraft

package
v0.0.0-...-bb60f61 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package minecraft contains utilities for obtaining statistics on minecraft servers.

Index

Constants

This section is empty.

Variables

View Source
var ErrStatus = errors.New("unexpected status code")

ErrStatus is the error given when an HTTP call to the minecraft status endpoint returns an error status code.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

The Client type is used to obtain statistical information on Minecraft servers. It makes HTTP requests to https://ac.mcsrvstat.us, using their API to get server info.

func NewClient

func NewClient(addr string) *Client

NewClient returns a new instance of the Client type that will check the status of the provided minecraft server address.

func (*Client) GetStatus

func (c *Client) GetStatus(ctx context.Context) (*ServerStatus, error)

GetStatus returns a ServerStatus instance containing statistical information about the desired Minecraft server.

type MOTD

type MOTD struct {
	Raw   []string `json:"raw"`
	Clean []string `json:"clean"`
	HTML  []string `json:"html"`
}

MOTD contains the "message of the day" data for a Minecraft server.

type Players

type Players struct {
	Online int      `json:"online"`
	Max    int      `json:"max"`
	List   []string `json:"list"`
}

Players contains the current players on a Minecraft server.

type ServerStatus

type ServerStatus struct {
	IP       string  `json:"ip"`
	Port     int     `json:"port"`
	MOTD     MOTD    `json:"motd"`
	Players  Players `json:"players"`
	Version  string  `json:"version"`
	Online   bool    `json:"online"`
	Protocol int     `json:"protocol"`
}

ServerStatus represents the JSON response when querying the status of a Minecraft server.

Jump to

Keyboard shortcuts

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