mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
37 lines
No EOL
1.2 KiB
PHP
37 lines
No EOL
1.2 KiB
PHP
<?php
|
|
|
|
class QueryAPI{
|
|
|
|
public static $NOT_FOUND_VALUE = null;
|
|
private $queryData;
|
|
private $server;
|
|
|
|
public function __construct(){
|
|
$this->server = ServerAPI::request();
|
|
$this->updateQueryData("splitnum", chr(128));
|
|
$this->updateQueryData("hostname", $this->server->name);
|
|
$this->updateQueryData("gametype", ($this->server->gamemode & 0x01) === 0 ? "SMP" : "CMP");
|
|
$this->updateQueryData("game_id", "MINECRAFTPE");
|
|
$this->updateQueryData("version", CURRENT_MINECRAFT_VERSION);
|
|
$this->updateQueryData("server_engine", "NostalgiaCore " . MAJOR_VERSION);
|
|
$this->addToQuery("plugins");
|
|
$this->addToQuery("map");
|
|
$this->addToQuery("numplayers");
|
|
$this->updateQueryData("maxplayers", $this->server->maxClients);
|
|
$this->updateQueryData("whitelist", $this->server->api->getProperty("white-list") === true ? "on" : "off");
|
|
$this->updateQueryData("hostport", $this->server->api->getProperty("server-port"));
|
|
$this->addToQuery("tps");
|
|
}
|
|
|
|
public function updateQueryData($name, $value){
|
|
$this->queryData[$name] = $value;
|
|
}
|
|
|
|
public function addToQuery($name){
|
|
$this->updateQueryData($name, QueryAPI::$NOT_FOUND_VALUE);
|
|
}
|
|
|
|
public function getQueryData(){
|
|
return $this->queryData;
|
|
}
|
|
} |