This commit is contained in:
GameHerobrine 2022-07-23 02:31:28 +03:00
parent ce25cfbbc0
commit 34287bb101
2 changed files with 11 additions and 20 deletions

View file

@ -28,8 +28,7 @@ class ServerAPI{
private $apiList = array();
private $asyncCnt = 0;
private $rcon;
public $query;
public $queryAPI;
//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("player", "PlayerAPI");
$this->loadAPI("time", "TimeAPI");
$this->loadAPI("queryAPI", "QueryAPI");
foreach($this->apiList as $ob){
if(is_callable(array($ob, "init"))){
$ob->init(); //Fails sometimes!!!
@ -182,6 +181,7 @@ class ServerAPI{
}
$this->loadAPI("plugin", "PluginAPI"); //fix :(
$this->plugin->init();
}
public function async(callable $callable, $params = array(), $remove = false){

View file

@ -41,7 +41,7 @@ class QueryHandler{
Then, the Query class handles itself sending the packets in raw form, because
packets can conflict with the MCPE ones.
*/
$this->server->schedule(20 * 30, array($this, "regenerateToken"), array(), true);
$this->regenerateToken();
$this->lastToken = $this->token;
@ -62,22 +62,13 @@ class QueryHandler{
$plist = substr($plist, 0, -1);
}
}
$KVdata = array(
"splitnum" => chr(128),
"hostname" => $this->server->name,
"gametype" => ($this->server->gamemode & 0x01) === 0 ? "SMP":"CMP",
"game_id" => "MINECRAFTPE",
"version" => CURRENT_MINECRAFT_VERSION,
"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"],
);
$this->server->api->queryAPI->updateQueryData("plugins", $plist);
$this->server->api->queryAPI->updateQueryData("map", $this->server->api->level->getDefault()->getName());
$this->server->api->queryAPI->updateQueryData("numplayers", count($this->server->clients));
$this->server->api->queryAPI->updateQueryData("tps", $this->server->debugInfo()["tps"]);
$this->server->api->dhandle("query.update", null);
$KVdata = $this->server->api->queryAPI->getQueryData();
foreach($KVdata as $key => $value){
$str .= $key."\x00".$value."\x00";
}