fragland/minestat

Minecraft服务器状态检查器

3.0.1 2024-03-30 19:45 UTC

This package is auto-updated.

Last update: 2024-09-30 20:46:00 UTC


README

PHP/Packagist/composer包,用于MineStat

PHP示例

注意: PHP版的MineStat需要多字节字符串支持来处理字符编码转换。启用mbstring支持可能只需安装适用于您平台的php-mbstring包。如果从源构建PHP,请参阅https://php.ac.cn/manual/en/mbstring.installation.php。验证时,如果功能已启用,则phpinfo()输出将引用mbstring

<?php
require_once('minestat.php');
$ms = new MineStat("frag.land");
// Bedrock/Pocket Edition explicit query example
//$ms = new MineStat("minecraft.frag.land", 19132, 5, MineStat::REQUEST_BEDROCK);
printf("Minecraft server status of %s on port %s:<br>", $ms->get_address(), $ms->get_port());
if($ms->is_online())
{
  printf("Server is online running version %s with %s out of %s players.<br>", $ms->get_version(), $ms->get_current_players(), $ms->get_max_players());
  if($ms->get_request_type() == "Bedrock/Pocket Edition")
    printf("Game mode: %s<br>", $ms->get_mode());
  printf("Message of the day: %s<br>", $ms->get_motd());
  printf("Message of the day without formatting: %s<br>", $ms->get_stripped_motd());
  printf("Latency: %sms<br>", $ms->get_latency());
  printf("Connected using protocol: %s<br>", $ms->get_request_type());
}
else
{
  printf("Server is offline!<br>");
}
?>