minecraft服务器查询不回显motd

时间:2014-04-22 07:13:18

标签: php minecraft

我从这里下载了代码:https://github.com/FunnyItsElmo/PHP-Minecraft-Server-Status-Query

我想通过以下代码回显服务器的MOTD:

<?php

include_once 'get.php'; //include the class
$status = new MinecraftServerStatus(); // call the class

$response = $status->getStatus('localhost'); // call the function

$statusTxt = "offline";
$version ="N/A";
$ping ="N/A";
$players = "0/0";
$host = "N/A";
$motd = "N/A";
$version= "N/A";

if($response){
    $statusTxt="online";
    $players = $response['players'] . "/" . $response['maxplayers'];
    $version = $response['version'];
    $ping = $response['ping'];
    $host = $response['hostname'];
    $motd = $response['motd'];
    $version = $response['version'];
}

?>
<div id="banner">
<div id="status"><?php
echo$statusTxt;
?></div>
<div id="version"><?php
echo$version;
?></div>
<div id="ping"><?php
echo$ping;
?></div>
<div id="players"><?php
echo$players; 
?></div>
<div id="host"><?php
echo $host; 
?></div>
<div id="motd"><?php
echo $motd; echo $version;
?></div>
</div>

但是返回:

online
103
3/100
localhost
1.7.5

如何回显服务器的MOTD?

1 个答案:

答案 0 :(得分:0)

我建议只使用Auto Bukkit,对于Minecraft服务器来说非常简单,而且MOTD在100%的时间都可以工作。