定制 adrien-nf/minecraft-server-status 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

adrien-nf/minecraft-server-status

最新稳定版本:1.0.1

Composer 安装命令:

composer require adrien-nf/minecraft-server-status

包简介

Get informations from a Minecraft server in real time.

README 文档

README

Get informations from a Minecraft server in real time.

Installation

Via composer

composer require adrien-nf/minecraft-server-status

Usage

Server List Ping

No configuration needed from the server, this is the easiest method.

use Ping\Ping;

$infos = (new Ping("localhost", 25565))->getInfos();

echo $infos->getVersion(); // 1.20.1
echo $infos->getServerType(); // Vanilla
echo $infos->getMotd(); // A Minecraft Server
echo $infos->getMaxPlayers(); // 20
echo $infos->getPlayersCount(); // 3
echo $infos->getIp(); // localhost
echo $infos->getPort(); // 25565

// With Ping, you only get a partial player list
var_dump($infos->getPlayers()); // ["Notch", "Deadmau5"]

// Some helper functions
echo $infos->isPlayerConnected("Notch"); // true
echo $infos->isVanilla(); // true
echo $infos->isBukkit(); // false
echo $infos->isSpigot(); // false
echo $infos->isPaper(); // false

Query

Requires configuration in server.properties:

  • enable-query=true
  • query.port=25565

Once this is done, usage is pretty straightforward.

use Queries\JavaServerQuery;

$infos = (new JavaServerQuery("localhost", 25565))->getInfos();

echo $infos->getGameType(); // SMP
echo $infos->getWorldName(); // world

// With Query, you get a full players list
var_dump($infos->getPlayers()); // ["Notch", "Deadmau5", "Jeb"]
var_dump($infos->getPlugins()); // [["name" => "Shopkeepers", "version" => "2.17.1"], ["name" => "HolographicDisplays", "version" => "3.0.2"]]

// Some helper functions
echo $infos->getPluginsAsString(); // "Shopkeepers, HolographicDisplays"
echo $infos->getPluginsAsString(true); // "Shopkeepers 2.17.1, HolographicDisplays 3.0.2"
echo $infos->hasPlugin("Shopkeepers"); // true
var_dump($infos->getPluginsAsArray()) // ["Shopkeepers", "HolographicDisplays"]
var_dump($infos->getPluginsAsArray(true)) // ["Shopkeepers 2.17.1", "HolographicDisplays 3.0.2"]

Credits

This package has been inspired by xPaw's package, extended and corrected for simpler usage.

统计信息

  • 总下载量: 19
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-08-06