• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

noxifoxi/minecraft-server-status: Minecraft server status script for PHP

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

noxifoxi/minecraft-server-status

开源软件地址(OpenSource Url):

https://github.com/noxifoxi/minecraft-server-status

开源编程语言(OpenSource Language):

PHP 100.0%

开源软件介绍(OpenSource Introduction):

Lightweight Minecraft server status script for PHP

Copyright noxifoxi https://github.com/noxifoxi/minecraft-server-status

This lightweight script queries the server information from Minecraft java servers.

MinecraftServerStatus.class.php (Minecraft 1.0.0+) uses the query method and supports all servers with enabled queries. MinecraftServerStatusSimple.class.php (Minecraft Beta 1.8+) can be used as a fallback if the server does not permit queries, if something else goes wrong or just a simple request is required.

Features

  • Queries the server if the server setting enable-query is enabled and parses the server infos.
  • Fallback to read and parse the build-in server infos from Minecraft Beta 1.8+ servers.
  • OOPHP
  • Error handling
  • Easy to use
  • Lightweight

Requirements

  • PHP 5.4.0+
  • PHP stream sockets (stream_socket_client, fwrite, fread, fclose)

How to use the script

The server.properties has to include the following settings:

enable-query=true
query.port=25565
<?php
require_once('MinecraftServerStatus.class.php');
$Server = new MinecraftServerStatus('example-minecraft-host.com');
?>
MinecraftServerStatus($Host, $Port = 25565, $Timeout = 1)

Check online/offline

$Server->Get('online');

If the server is online the return value is true otherwise its false.

Get player count

echo $Server->Get('numplayers').' / '.$Server->Get('maxplayers');

Get a list of the online players names

foreach($Server->Get('players') as $Player)
	echo $Player.'<br>';

$Server->Get('players') returns an array of strings,

Get everything

$ServerStatus = $Server->Get();

Returns an array with every information the script was able to fetch.

All available "hooks"

Most of these hooks are only available if the server has query enabled or is non-vanilla.

'hostname'
'gametype'
'game_id'
'version'
'plugins'
'map'
'numplayers'
'maxplayers'
'hostport'
'hostip'
'online'
'software'

Check if $Server->Get('hook'); returns the expected value (No hook = false).

Fallback

MinecraftServerStatus.class.php automatically falls back using MinecraftServerStatusSimple.class.php if the file is present in the same folder. Providing less information, but information at all.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap