本文整理汇总了PHP中pocketmine\Server::getNetwork方法的典型用法代码示例。如果您正苦于以下问题:PHP Server::getNetwork方法的具体用法?PHP Server::getNetwork怎么用?PHP Server::getNetwork使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\Server
的用法示例。
在下文中一共展示了Server::getNetwork方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: check
public function check()
{
$d = Utils::getRealMemoryUsage();
$u = Utils::getMemoryUsage(true);
$usage = round($u[0] / 1024 / 1024, 2) . "/" . round($d[0] / 1024 / 1024, 2) . "/" . round($u[1] / 1024 / 1024, 2) . "/" . round($u[2] / 1024 / 1024, 2) . " MB @ " . Utils::getThreadCount() . " threads";
$serverStatus = serialize(["online" => count($this->server->getOnlinePlayers()), "max" => $this->server->getMaxPlayers(), "upload" => round($this->server->getNetwork()->getUpload() / 1024, 2), "download" => round($this->server->getNetwork()->getDownload() / 1024, 2), "tps" => $this->server->getTicksPerSecondAverage(), "load" => $this->server->getTickUsageAverage(), "usage" => $usage]);
for ($n = 0; $n < $this->threads; ++$n) {
if (!$this->workers[$n]->isTerminated()) {
$this->workers[$n]->serverStatus = $serverStatus;
}
if ($this->workers[$n]->isTerminated() === true) {
$this->workers[$n] = new RCONInstance($this->socket, $this->password, $this->clientsPerThread);
} elseif ($this->workers[$n]->isWaiting()) {
if ($this->workers[$n]->response !== "") {
$this->server->getLogger()->info($this->workers[$n]->response);
$this->workers[$n]->synchronized(function (RCONInstance $thread) {
$thread->notify();
}, $this->workers[$n]);
} else {
$response = new RemoteConsoleCommandSender();
$command = $this->workers[$n]->cmd;
$this->server->getPluginManager()->callEvent($ev = new RemoteServerCommandEvent($response, $command));
if (!$ev->isCancelled()) {
$this->server->dispatchCommand($ev->getSender(), $ev->getCommand());
}
$this->workers[$n]->response = $response->getMessage();
$this->workers[$n]->synchronized(function (RCONInstance $thread) {
$thread->notify();
}, $this->workers[$n]);
}
}
}
}
示例2: sendServerInfo
/**
* @param CommandSender $sender
* @param Server $server
*/
public function sendServerInfo(CommandSender $sender, Server $server)
{
$sender->sendMessage("Name: " . $server->getServerName());
$sender->sendMessage("Motd: " . $server->getMotd());
$sender->sendMessage("Network-motd: " . $server->getNetwork()->getMotd());
$sender->sendMessage("Address: " . $server->getIp() . ":" . $server->getPort());
$sender->sendMessage("Players: " . count($server->getOnlinePlayers()) . "/" . $server->getMaxPlayers());
$sender->sendMessage("Difficulty: " . $server->getDifficulty());
$sender->sendMessage("Default-gamemode: " . $server->getDefaultGamemode());
$sender->sendMessage("Unique-id: " . $server->getServerUniqueId());
$sender->sendMessage("TPS: " . $server->getTicksPerSecond());
$sender->sendMessage("Average-TPS: " . $server->getTicksPerSecondAverage());
$sender->sendMessage("Codename: " . $server->getCodename());
$sender->sendMessage("API-version: " . $server->getApiVersion());
$sender->sendMessage("MCPE-version: " . $server->getVersion());
$sender->sendMessage("Is-hardcore: " . ($server->isHardcore() ? TextFormat::GREEN . "yes" : TextFormat::RED . "no"));
$sender->sendMessage("Is-running: " . ($server->isRunning() ? TextFormat::GREEN . "yes" : TextFormat::RED . "no"));
$sender->sendMessage("Is-whitelisted: " . ($server->hasWhitelist() ? TextFormat::GREEN . "yes" : TextFormat::RED . "no"));
}
示例3: debugSysVars
/**
* @param Server $server - pocketmine Server
* @param array &$vars - variables
*/
public static function debugSysVars(Server $server, &$vars)
{
// Enable debugging variables...
$time = microtime(true) - \pocketmine\START_TIME;
$uptime = "";
$q = "";
foreach ([["sec", 60, 1, "secs"], ["min", 60, 60, "mins"], ["hour", 24, 60, "hours"], ["day", 0, 24, "days"]] as $f) {
if ($f[1]) {
$e = floor($time % $f[1]);
}
$time = floor($time / $f[2]);
if ($e) {
$r = $e == 1 ? $f[0] : $f[3];
$uptime = $e . " " . $r . $q . $uptime;
$q = ", ";
}
}
$vars["{uptime}"] = $uptime;
$vars["{netup}"] = round($server->getNetwork()->getUpload() / 1024, 2);
$vars["{netdown}"] = round($server->getNetwork()->getUpload() / 1024, 2);
$vars["{threads}"] = Utils::getThreadCount();
$mUsage = Utils::getMemoryUsage(true);
$vars["{mainmem}"] = number_format(round($mUsage[0] / 1024) / 1024, 2);
$vars["{memuse}"] = number_format(round($mUsage[1] / 1024) / 1024, 2);
$vars["{maxmem}"] = number_format(round($mUsage[2] / 1024) / 1024, 2);
$rUsage = Utils::getRealMemoryUsage();
$vars["{heapmem}"] = number_format(round($rUsage[0] / 1024) / 1024, 2);
}