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


PHP Server::dispatchCommand方法代码示例

本文整理汇总了PHP中pocketmine\Server::dispatchCommand方法的典型用法代码示例。如果您正苦于以下问题:PHP Server::dispatchCommand方法的具体用法?PHP Server::dispatchCommand怎么用?PHP Server::dispatchCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pocketmine\Server的用法示例。


在下文中一共展示了Server::dispatchCommand方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: check

 public function check()
 {
     for ($n = 0; $n < $this->threads; ++$n) {
         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 = TextFormat::clean($response->getMessage());
                 $this->workers[$n]->synchronized(function (RCONInstance $thread) {
                     $thread->notify();
                 }, $this->workers[$n]);
             }
         }
     }
 }
开发者ID:ClearSkyTeam,项目名称:ClearSky,代码行数:26,代码来源:RCON.php

示例2: 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

示例3: onCompletion

 public function onCompletion(Server $server)
 {
     $this->cache = unserialize($this->cache);
     $this->data = unserialize($this->data);
     $obj = json_decode($this->data, true);
     $player = $server->getPlayer($this->player);
     if (empty($obj)) {
         if ($this->mode == 1) {
             $server->getLogger()->critical("API Server Seems to be Down");
             if (!$this->cfg["bypass-check"]) {
                 $player->close("", $this->cfg["bypass-message"]);
             }
         } else {
             if ($this->mode == 2) {
                 $player->sendMessage("API Server Seems to be Down, try again later.");
             }
         }
     } else {
         if ($obj['status'] === "success") {
             //Cache only if API returned success status string
             if ($this->cache instanceof SimpleCache) {
                 if (!$this->cache->is_cached($this->ip)) {
                     $this->cache->set_cache($this->ip, $this->data);
                 }
             }
             if ($obj['host-ip']) {
                 $provider = $obj["org"];
                 $countryCode = $obj["cc"];
                 if ($this->mode == 1) {
                     if ($player != null) {
                         foreach ($this->cfgCommands as $command) {
                             $command = str_replace("%p", $player->getName(), $command);
                             $server->dispatchCommand(new ConsoleCommandSender(), $command);
                         }
                         if ($this->cfg["logging"]) {
                             $server->getLogger()->info(TextFormat::DARK_RED . $player->getName() . TextFormat::WHITE . " has been disconnected for using an anonymizer: IP Details -> " . $provider . "," . $countryCode);
                         }
                     }
                 } else {
                     if ($this->mode == 2) {
                         $player->sendMessage($this->ip . " belongs to a hosting organization");
                         $player->sendMessage("IP Details: " . $provider . "," . $countryCode);
                     }
                 }
             } else {
                 if ($this->mode == 1) {
                     if ($player != null) {
                         if ($this->cfg["logging"]) {
                             $server->getLogger()->info(TEXTFormat::GREEN . $player->getName() . TextFormat::WHITE . " has passed VPNGuard checks.");
                         }
                     }
                 } else {
                     if ($this->mode == 2) {
                         $player->sendMessage($this->ip . " does not seem to belong to a hosting organization.");
                         $player->sendMessage("If you believe this is an error please report it to us to have it fixed.");
                     }
                 }
             }
         } else {
             if ($this->mode == 1) {
                 if ($player != null) {
                     $server->getLogger()->warning(TextFormat::WHITE . "API Server Returned Error Message: " . TextFormat::RED . $obj['msg'] . TextFormat::WHITE . " when " . TextFormat::GOLD . $player->getName() . TextFormat::WHITE . " tried to connect");
                     if ((strpos($obj['msg'], "Invalid API Key") || strpos($obj['msg'], "Payment Overdue")) === false) {
                         $server->getLogger()->critical("Shutting down server to prevent blacklisting on API Database");
                         $server->shutdown();
                         return;
                     } else {
                         if (!$this->cfg["bypass-check"]) {
                             $player->close("", $this->cfg["bypass-message"]);
                         }
                     }
                 }
             } else {
                 if ($this->mode == 2) {
                     $player->sendMessage("API Server Returned Error Message: " . $obj["msg"]);
                 }
             }
         }
     }
 }
开发者ID:Samistine,项目名称:VPNGuard,代码行数:80,代码来源:Async.php


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