3.4 KiB
Minecraft Server Status Checker
This project provides two Go programs to query the status of Minecraft servers: one for Bedrock Edition (statusBedrock.go
) and one for Java Edition (status.go
). Both programs use the mcstatus-io/mcutil
library to fetch server information and output the results in formatted JSON.
Features
- Query Minecraft server status for Bedrock or Java Edition.
- Configurable hostname and port via command-line flags.
- Timeout handling to prevent hanging on unresponsive servers.
- Formatted JSON output for easy parsing or reading.
- Lightweight and simple to use.
Prerequisites
- Go (version 1.16 or later recommended)
- Internet access to query the Minecraft server
- The
mcstatus-io/mcutil
library (automatically installed viago get
)
Installation
-
Clone or download this repository:
git clone https://git.ssh.surf/hypermc/mc-status.git cd mc-status
-
Install the required Go module:
go get github.com/mcstatus-io/mcutil/v4
-
Ensure your Go environment is set up correctly (
go mod init
if needed).
Usage
Bedrock Edition (statusBedrock.go
)
This program queries a Minecraft Bedrock Edition server.
-
Compile the program:
go build statusBedrock.go
-
Run the program with default settings (queries
my-mc.link:25565
):./statusBedrock
-
Customize the hostname and port using flags:
./statusBedrock -host=example.com -port=19132
Java Edition (status.go
)
This program queries a Minecraft Java Edition server.
-
Compile the program:
go build status.go
-
Run the program with default settings (queries
my-mc.link:25565
):./status.go
-
Customize the hostname and port using flags:
./status.go -host=example.com -port=25565
Example Output
Running either program will output the server status in JSON format. For example:
{
"version": {
"name": "1.20.1",
"protocol": 763
},
"players": {
"online": 5,
"max": 20
},
"description": {
"text": "Welcome to My Minecraft Server!"
},
"favicon": "data:image/png;base64,...",
"ping": 45
}
Command-Line Flags
Both programs support the following flags:
-host
: Specifies the server hostname (default:my-mc.link
).-port
: Specifies the server port (default:25565
for Java, often19132
for Bedrock).
Notes
- The Bedrock program (
statusBedrock.go
) uses a 20-second timeout, while the Java program (status.go
) uses a 5-second timeout. Adjust these in the source code if needed. - Ensure the server is online and accessible. Firewalls or network issues may cause errors.
- The
mcstatus-io/mcutil
library handles the protocol details, supporting modern Minecraft server versions.
Troubleshooting
- Error: "context deadline exceeded": The server is unreachable or took too long to respond. Check the hostname, port, and server status.
- Error: "json: cannot unmarshal": The server response was malformed. Ensure the server is running a compatible version.
- Dependency issues: Run
go mod tidy
to resolve missing or outdated dependencies.
Acknowledgments
- Thanks to mcstatus-io for the
mcutil
library. - Inspired by the need for simple, reliable Minecraft server status tools.