8000 GitHub - Sch8ill/mclib at v0.1.3
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Sch8ill/mclib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mclib

Release doc Go Report Card MIT license


The mclib package provides utilities for interacting with Minecraft servers using the Server List Ping (SLP) protocol. It includes functionality to query Minecraft servers for status and latency information.

Installation

To use this package in your Go project, simply install it:

go get github.com/sch8ill/mclib

Usage

MCServer

MCServer represents a Minecraft server with its address and client. It provides methods to retrieve server status and perform a status ping.

Creating an MCServer Instance

package main

import (
	"github.com/sch8ill/mclib/server"
)

func main() {
	srv, err := server.New("example.com:25565")
	if err != nil {
		// handle error
	}
}

StatusPing

res, err := srv.StatusPing()
if err != nil {
// handle error
}

fmt.Printf("version: %s\n", res.Version.Name)
fmt.Printf("protocol: %d\n", res.Version.Protocol)
fmt.Printf("online players: %d\n", res.Players.Online)
fmt.Printf("max players: %d\n", res.Players.Max)
fmt.Printf("sample players: %+q\n", res.Players.Sample)
fmt.Printf("description: %s\n", res.Description.String())
fmt.Printf("latency: %dms\n", res.Latency)
// ... 

Ping

latency, err := srv.ping()
if err != nil {
// handle error
}

fmt.Printf("latency: %dms\n", latency)

Cli

Build

requires:

make
go >= 1.20

build:

make build && mv build/mcli mcli

Usage

mclib also provides a simple command line interface:

  -addr string
        the server address (default "localhost")
  -srv
        whether a srv lookup should be made (default true)
  -timeout duration
        the connection timeout (default 5s)

For example:

mcli --addr hypixel.net --timeout 10s

License

This package is licensed under the MIT License.


About

A Minecraft client to retrieve status information via the SLP protocol

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published
0