mcpinger

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2021 License: MIT Imports: 9 Imported by: 0

README

MC Pinger

Provides an interface for pinging Minecraft servers via the Server List Ping interface.

Documentation

Index

Constants

View Source
const (
	UnknownProtoVersion = -1
	StatusState         = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatComponent

type ChatComponent struct {
	RegularChatComponent
}

Wraps a RegularChatComponent for parsing both regular & string-only MOTD's

func (*ChatComponent) UnmarshalJSON

func (c *ChatComponent) UnmarshalJSON(data []byte) error

type InvalidPacketError

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

InvalidPacketError returned when the received packet type does not match the expected packet type.

func (InvalidPacketError) Error

func (i InvalidPacketError) Error() string

type Pinger

type Pinger interface {
	Ping() (*ServerInfo, error)
}

Pinger allows you to retrieve server info.

func New

func New(host string, port uint16) Pinger

New Creates a new Pinger with specified host & port to connect to a minecraft server

func NewTimed

func NewTimed(host string, port uint16, timeout time.Duration) Pinger

Creates a new Pinger with specified host & port to connect to a minecraft server

type Player

type Player struct {
	Name string `json:"name"` // Player name
	ID   string `json:"id"`   // Player UUID
}

Server info player

type Players

type Players struct {
	Max    uint     `json:"max"`    // Max amount of players allowed
	Online uint     `json:"online"` // Amount of players online
	Sample []Player // Sample of online players
}

Server info players

type RegularChatComponent

type RegularChatComponent struct {
	Text          string                 `json:"text"`          // Text content
	Bold          bool                   `json:"bold"`          // Component is emboldened
	Italic        bool                   `json:"italic"`        // Component is italicized
	Underlined    bool                   `json:"underlined"`    // Component is underlined
	Strikethrough bool                   `json:"strikethrough"` // Component is struck out
	Obfuscated    bool                   `json:"obfuscated"`    // Component randomly switches between characters of the same width
	Color         string                 `json:"color"`         // Contains the color for the component
	Extra         []RegularChatComponent `json:"extra"`         // RegularChatComponent siblings
}

Minecraft chat component See: https://wiki.vg/Chat#Current_system_.28JSON_Chat.29

type ServerInfo

type ServerInfo struct {
	Version     Version       `json:"version"`     // Server version info
	Players     Players       `json:"players"`     // Server player info
	Description ChatComponent `json:"description"` // Server description
	Favicon     string        `json:"favicon"`     // Server favicon
}

Server ping response https://wiki.vg/Server_List_Ping#Response

type Version

type Version struct {
	Name     string `json:"name"`     // Version name
	Protocol uint   `json:"protocol"` // Version protocol number
}

Server info version

Directories

Path Synopsis
_example

Jump to

Keyboard shortcuts

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