minequery

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2019 License: MIT Imports: 5 Imported by: 0

README

go-minequery Go Report Card GoDoc

A wrapper for querying Minequery enabled Minecraft servers in Go. Minequery was a community protocol for fetching Minecraft server information prior to the implementation of Minecraft's official Server List Ping protocol. Its use is rare and is largely a legacy compatibility layer for outdated Minecraft server versions.

Usage

Installation

Install using go get github.com/Cryptkeeper/go-minequery

Example Usage
package main

import (
	"fmt"
	"github.com/Cryptkeeper/go-minequery"
	"log"
	"time"
)

func main() {
	resp, err := minequery.Query("myip", 25566, time.Second * 5)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%d/%d players are online.", resp.PlayerCount, resp.MaxPlayers)
}

(The default Minequery port, 25566, is also available as a const, minequery.DefaultPort.)

Response

The response structure is described in minequery.Response

Compatibility

go-minequery should be compatible with any Minequery protocol implementation that supports QUERY_JSON, introduced in version 1.3 (2011). Later implementations expanded the protocol to include additional metadata. go-minequery does not support this extended metadata in order to maximize compatibility.

Documentation

Overview

Package minequery is a simple library to query Minequery enabled Minecraft servers.

Index

Constants

View Source
const (
	// DefaultPort is the default Minequery network port.
	// More information: https://github.com/vexsoftware/minequery/blob/v1.5/java/net/minestatus/minequery/Minequery.java#L65
	DefaultPort = 25566
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Response

type Response struct {
	ServerPort  int      `json:"serverPort"`
	PlayerCount int      `json:"playerCount"`
	MaxPlayers  int      `json:"maxPlayers"`
	PlayerList  []string `json:"playerList"`
}

Response is a representation of the Minequery server QUERY_JSON response. More information: https://github.com/vexsoftware/minequery/blob/v1.5/java/net/minestatus/minequery/Request.java#L108

func Query

func Query(address string, port uint16, timeout time.Duration) (Response, error)

Query connects and requests a response from the Minequery server at the specified address. Follows Minequery server's Java implementation: https://github.com/vexsoftware/minequery/blob/v1.5/java/net/minestatus/minequery/Request.java#L21

Jump to

Keyboard shortcuts

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