officialbalazs / minecraftserverstatus
⚡ Lightweight library to query any Minecraft server's status, and basic information.
This package's canonical repository appears to be gone and the package has been frozen as a result.
1.1.0
2019-08-03 22:29 UTC
Requires (Dev)
- phpunit/phpunit: ^8.3
This package is auto-updated.
Last update: 2021-12-26 14:00:25 UTC
README
⚡ Lightweight library to query any Minecraft server's status, and basic information.
Tested with Spigot 1.9 and Bungeecord 1.9 & 1.8
Installation
composer require officialbalazs/minecraftserverstatus
Tutorial
use MinecraftServerStatus\MinecraftServerStatus; require '../vendor/autoload.php'; $response = MinecraftServerStatus::query('lostforce.com', 25565); if (! $response) { echo "The Server is offline!"; } else { echo "<img width=\"64\" height=\"64\" src=\"" . $response['favicon'] . "\" /> <br> The Server " . $response['hostname'] . " is running on " . $response['version'] . " and is online, currently are " . $response['players'] . " players online of a maximum of " . $response['max_players'] . ". The motd of the server is '" . $response['description'] . "'. The server has a ping of " . $response['ping'] . " milliseconds."; }
If the server is offline MinecraftServerStatus::query returns false else it returns an array which contains the server informations.
Variables
The following table contains the available variables the response can contain. The default value of each variable is false.
Array Index | Description |
---|---|
'hostname' |
Exact server address in 127.0.0.1 format |
'port' |
The servers port for example 25565 |
'ping' |
The time in ms the server needs to answer |
'version' |
The server version (for example: 1.9) |
'protocol' |
The server protocol (for example: 107) |
'players' |
Amount of players who are currently online |
'max_players' |
Number of the slots of the server |
'description' |
The message of the day of the server |
'description_raw' |
The raw version of description (contains color codes etc.) |
'favicon' |
The favicon of the server in a base64 string (Can be displayed with the html img tag by setting the string as src) |
'modinfo' |
Informations about the plugins |