officialbalazs/minecraftserverstatus

⚡ 轻量级库,用于查询任何Minecraft服务器的状态和基本信息。

该包的规范仓库似乎已消失,因此该包已被冻结。

1.1.0 2019-08-03 22:29 UTC

This package is auto-updated.

Last update: 2021-12-26 14:00:25 UTC


README

StyleCI

⚡ 轻量级库,用于查询任何Minecraft服务器的状态和基本信息。

与Spigot 1.9和Bungeecord 1.9 & 1.8进行了测试

安装

composer require officialbalazs/minecraftserverstatus

教程

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.";
}

如果服务器离线,MinecraftServerStatus::query 返回 false,否则返回一个包含服务器信息的数组。

变量

以下表格包含响应中可能包含的可用变量。每个变量的默认值都是 false。

数组索引 描述
'hostname'
精确的服务器地址,以 127.0.0.1 格式
'port'
服务器的端口号,例如 25565
'ping'
服务器响应所需的时间(毫秒)
'version'
服务器版本
(例如:1.9)
'protocol'
服务器协议
(例如:107)
'players'
当前在线玩家的数量
'max_players'
服务器的槽位数量
'description'
服务器每日消息
'description_raw'
描述的原始版本
(包含颜色代码等。)
'favicon'
服务器favicon的base64字符串
(可以通过将字符串设置为src来使用html img标签显示)
'modinfo'
有关插件的详细信息