当前位置: 首页>>代码示例>>PHP>>正文


PHP Server::getNetwork方法代码示例

本文整理汇总了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]);
             }
         }
     }
 }
开发者ID:iTXTech,项目名称:Genisys,代码行数:33,代码来源:RCON.php

示例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"));
 }
开发者ID:happyexceed,项目名称:PocketMine-Plugins-1,代码行数:23,代码来源:InfoFetcher.php

示例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);
 }
开发者ID:jigibbs123,项目名称:pocketmine-plugins,代码行数:32,代码来源:ExpandVars.php


注:本文中的pocketmine\Server::getNetwork方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。