mcping

package module
v0.0.0-...-45b6a3b Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2016 License: MIT Imports: 11 Imported by: 3

README

MCPing

A Golang library that facilitates Minecraft 1.7 server list pings.

[Godoc] (https://godoc.org/github.com/ammario/mcping)

Install

go get github.com/ammario/mcping

Usage

package main

import (
    "github.com/ammario/mcping"
    "fmt"
)

func main() {
    resp, err := mcping.Ping("us.mineplex.com:25565")
    fmt.Println("Mineplex has", resp.Online, "players online")
}

Response Struct

The struct returned by the Ping() function has the following schema

type PingResponse struct {
    Latency  uint   //Latency in ms
    Online   int    //Amount of online players
    Max      int    //Maximum amount of players
    Protocol int    //E.g '4'
    Favicon  string //Base64 encoded favicon in data URI format
    Motd     string
    Server   string //E.g 'PaperSpigot'
    Version  string //E.g "1.7.10"
    Sample   []PlayerSample
}
PlayerSample struct
type PlayerSample struct {
    UUID string //e.g "d8a973a5-4c0f-4af6-b1ea-0a76cd210cc5"
    Name string //e.g "Ammar"
}

Future Plans

  • Pre 1.7 ping

Documentation

Overview

Package mcping facilitates the pinging of Minecraft servers using the 1.7+ protocol.

Index

Constants

View Source
const (
	//DefaultTimeout stores default ping timeout
	DefaultTimeout = time.Second
)

Variables

View Source
var ErrAddress = errors.New("mcping: could not parse address")

ErrAddress -> Could not parse address

View Source
var ErrBigPacket = errors.New("mcping: Response too large")

ErrBigPacket -> Response is too large

View Source
var ErrPacketType = errors.New("mcping: Response packet type incorrect")

ErrPacketType -> Response packet incorrect

View Source
var ErrResolve = errors.New("mcping: Could not resolve address")

ErrResolve -. Could not resolve address

View Source
var ErrSmallPacket = errors.New("mcping: Response too small")

ErrSmallPacket -> Response is too small

View Source
var ErrTimeout = errors.New("mcping: Timeout occured")

ErrTimeout -> Timeout error

Functions

This section is empty.

Types

type PingResponse

type PingResponse struct {
	Latency  uint           `json:"latency"`  //Latency in ms
	Online   int            `json:"online"`   //Amount of online players
	Max      int            `json:"max"`      //Maximum amount of players
	Protocol int            `json:"protocol"` //E.g '4'
	Favicon  []byte         `json:"favicon"`  //Base64 encoded favicon in data URI format
	Motd     string         `json:"motd"`
	Server   string         `json:"server"`  //E.g 'PaperSpigot'
	Version  string         `json:"version"` //E.g "1.7.10"
	Sample   []PlayerSample `json:"sample"`
}

PingResponse contains all known fields of the ping response packet

func Ping

func Ping(addr string) (PingResponse, error)

Ping pings with default timeout

func PingTimeout deprecated

func PingTimeout(addr string, timeout int) (PingResponse, error)

Deprecated: PingTimeout Pings with custom timeout

func PingWithTimeout

func PingWithTimeout(addr string, timeout time.Duration) (PingResponse, error)

PingWithTimeout pings with custom timeout

type PlayerSample

type PlayerSample struct {
	UUID string `json:"uuid"` //e.g "d8a973a5-4c0f-4af6-b1ea-0a76cd210cc5"
	Name string `json:"name"` //e.g "Ammar"
}

PlayerSample contains a player response in the sample section of a ping response.

Jump to

Keyboard shortcuts

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