mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-22 04:29:43 +00:00
QueryAPI
This commit is contained in:
parent
ce25cfbbc0
commit
34287bb101
2 changed files with 11 additions and 20 deletions
|
|
@ -28,8 +28,7 @@ class ServerAPI{
|
||||||
private $apiList = array();
|
private $apiList = array();
|
||||||
private $asyncCnt = 0;
|
private $asyncCnt = 0;
|
||||||
private $rcon;
|
private $rcon;
|
||||||
|
public $queryAPI;
|
||||||
public $query;
|
|
||||||
|
|
||||||
//TODO: Instead of hard-coding functions, use PHPDoc-compatible methods to load APIs.
|
//TODO: Instead of hard-coding functions, use PHPDoc-compatible methods to load APIs.
|
||||||
|
|
||||||
|
|
@ -174,7 +173,7 @@ class ServerAPI{
|
||||||
$this->loadAPI("tile", "TileAPI");
|
$this->loadAPI("tile", "TileAPI");
|
||||||
$this->loadAPI("player", "PlayerAPI");
|
$this->loadAPI("player", "PlayerAPI");
|
||||||
$this->loadAPI("time", "TimeAPI");
|
$this->loadAPI("time", "TimeAPI");
|
||||||
|
$this->loadAPI("queryAPI", "QueryAPI");
|
||||||
foreach($this->apiList as $ob){
|
foreach($this->apiList as $ob){
|
||||||
if(is_callable(array($ob, "init"))){
|
if(is_callable(array($ob, "init"))){
|
||||||
$ob->init(); //Fails sometimes!!!
|
$ob->init(); //Fails sometimes!!!
|
||||||
|
|
@ -182,6 +181,7 @@ class ServerAPI{
|
||||||
}
|
}
|
||||||
$this->loadAPI("plugin", "PluginAPI"); //fix :(
|
$this->loadAPI("plugin", "PluginAPI"); //fix :(
|
||||||
$this->plugin->init();
|
$this->plugin->init();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function async(callable $callable, $params = array(), $remove = false){
|
public function async(callable $callable, $params = array(), $remove = false){
|
||||||
|
|
|
||||||
|
|
@ -62,22 +62,13 @@ class QueryHandler{
|
||||||
$plist = substr($plist, 0, -1);
|
$plist = substr($plist, 0, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$KVdata = array(
|
$this->server->api->queryAPI->updateQueryData("plugins", $plist);
|
||||||
"splitnum" => chr(128),
|
$this->server->api->queryAPI->updateQueryData("map", $this->server->api->level->getDefault()->getName());
|
||||||
"hostname" => $this->server->name,
|
$this->server->api->queryAPI->updateQueryData("numplayers", count($this->server->clients));
|
||||||
"gametype" => ($this->server->gamemode & 0x01) === 0 ? "SMP":"CMP",
|
$this->server->api->queryAPI->updateQueryData("tps", $this->server->debugInfo()["tps"]);
|
||||||
"game_id" => "MINECRAFTPE",
|
$this->server->api->dhandle("query.update", null);
|
||||||
"version" => CURRENT_MINECRAFT_VERSION,
|
$KVdata = $this->server->api->queryAPI->getQueryData();
|
||||||
"server_engine" => "NostalgiaCore ".MAJOR_VERSION,
|
|
||||||
"plugins" => $plist,
|
|
||||||
"map" => $this->server->api->level->getDefault()->getName(),
|
|
||||||
"numplayers" => count($this->server->clients),
|
|
||||||
"maxplayers" => $this->server->maxClients,
|
|
||||||
"whitelist" => $this->server->api->getProperty("white-list") === true ? "on":"off",
|
|
||||||
"hostport" => $this->server->api->getProperty("server-port"),
|
|
||||||
//"hostip" => $this->server->api->getProperty("server-ip", "0.0.0.0")
|
|
||||||
"tps" => $this->server->debugInfo()["tps"],
|
|
||||||
);
|
|
||||||
foreach($KVdata as $key => $value){
|
foreach($KVdata as $key => $value){
|
||||||
$str .= $key."\x00".$value."\x00";
|
$str .= $key."\x00".$value."\x00";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue