https://github.com/sch8ill/mclib
A Minecraft client to retrieve status information via the SLP protocol
https://github.com/sch8ill/mclib
golang minecraft-client minecraft-mod minecraft-ping minecraft-protocol minecraft-slp
Last synced: 19 days ago
JSON representation
A Minecraft client to retrieve status information via the SLP protocol
- Host: GitHub
- URL: https://github.com/sch8ill/mclib
- Owner: Sch8ill
- License: mit
- Created: 2023-10-14T22:50:59.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-03-31T20:32:50.000Z (about 1 month ago)
- Last Synced: 2025-04-13T00:08:30.616Z (19 days ago)
- Topics: golang, minecraft-client, minecraft-mod, minecraft-ping, minecraft-protocol, minecraft-slp
- Language: Go
- Homepage:
- Size: 1.92 MB
- Stars: 8
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mclib
[](https://github.com/sch8ill/mclib/releases)
[](https://pkg.go.dev/github.com/sch8ill/mclib)
[](https://goreportcard.com/report/github.com/sch8ill/mclib)
---
The `mclib` package provides utilities for interacting with Minecraft servers using
the [Minecraft protocol](https://wiki.vg/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:
```bash
go get github.com/sch8ill/mclib
```## Usage
### StatusPing
```go
package mainimport (
"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
```text
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
```go
package mainimport (
"fmt""github.com/sch8ill/mclib/fingerprint"
)func main() {
software, _ := fingerprint.Fingerprint("localhost")
fmt.Printf("software fingerprint: %s\n", software)
}
```#### output
```text
software fingerprint: craftbukkit
```Further documentation can be found on [pkg.go.dev](https://pkg.go.dev/github.com/sch8ill/mclib).
---
### Cli
#### Build
requires:
```
make
go >= 1.22
``````bash
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:
```bash
mcli --addr hypixel.net --timeout 10s
```---
## License
This package is licensed under the [MIT License](LICENSE).
---