Coder Social home page Coder Social logo

sch8ill / mclib Goto Github PK

View Code? Open in Web Editor NEW
6.0 1.0 0.0 1.96 MB

A Minecraft client to retrieve status information via the SLP protocol

License: MIT License

Makefile 0.64% Go 97.30% Shell 2.06%
golang minecraft-client minecraft-mod minecraft-protocol minecraft-slp minecraft-ping

mclib's Introduction

mclib

Release doc Go Report Card MIT license


The mclib package provides utilities for interacting with Minecraft servers using the Minecraft protocol. It includes functionality to query Minecraft servers for status and latency information. mclib is also capable of determining the software a server is running on by using fingerprinting techniques.


Installation

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

go get github.com/sch8ill/mclib

Usage

StatusPing

package main

import (
	"fmt"

	"github.com/sch8ill/mclib"
)

func main() {
	client, _ := mclib.NewClient("2b2t.org")
	res, _ := client.StatusPing()

	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)
}

output

version: Velocity 1.7.2-1.20.4
protocol: 47
online players: 571
max players: 1
sample players: [{"Fit" "fdee323e-7f0c-4c15-8d1c-0f277442342a"}]
description: 2B Updated to 1.19! 2T
latency: 8ms

Fingerprint

package main

import (
	"fmt"

	"github.com/sch8ill/mclib/fingerprint"
)

func main() {
	software, _ := fingerprint.Fingerprint("localhost")
	fmt.Printf("software fingerprint: %s\n", software)
}

output

software fingerprint: craftbukkit

Further documentation can be found on pkg.go.dev.


Cli

Build

requires:

make
go >= 1.22
make build

Usage

mclib also provides a simple command line interface:

  -addr string
        the server address (default "localhost")
  -fingerprint
        whether a software fingerprint should be performed on the server (default true)
  -protocol int
        the protocol version number the client should use (default 760)
  -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.


mclib's People

Contributors

sch8ill avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.