flycraftnetwork / minecraftserverstatus
此包已被弃用且不再维护。未建议替代包。
Minecraft服务器状态查询,用PHP编写,包含在线玩家、motd、favicon和更多服务器相关信息,无需插件和启用查询。
1.0.2.1
2018-02-16 18:11 UTC
This package is auto-updated.
Last update: 2020-08-23 02:42:13 UTC
README
Minecraft服务器状态查询,用PHP编写,包含在线玩家、motd、favicon和更多服务器相关信息,无需插件和启用查询。
在 stats.flycraft-network.net 上使用
原作者:FunnyItsElmo
安装
composer require flycraftnetwork/minecraftserverstatus
###教程
use MinecraftServerStatus\MinecraftServerStatus; require '../vendor/autoload.php'; $response = MinecraftServerStatus::query('play.flycraft-network.net', 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."; }
如果服务器离线,MinecraftServerStatus::query 返回 false,否则返回包含服务器信息的数组。
###变量 下表包含响应中可用的变量。每个变量的默认值是 false。
| 数组索引 | 描述 |
|---|---|
'hostname' |
IPv4格式或DNS记录中的精确服务器地址 |
'port' |
服务器的端口号,例如25565 |
'ping' |
服务器响应所需的时间(毫秒) |
'version' |
服务器版本 (例如:1.9) |
'protocol' |
服务器协议 (例如:107) |
'players' |
当前在线玩家的数量 |
'max_players' |
服务器的插槽数量 |
'description' |
服务器的每日消息 |
'description_raw' |
描述的原始版本 (包含颜色代码等。) |
'favicon' |
服务器favicon的base64字符串 (可以通过将字符串设置为src使用html img标签显示) |
'modinfo' |
有关插件的详细信息 |