php pocketmine-utils-Utils类(方法)实例源码

下面列出了php pocketmine-utils-Utils 类(方法)源码代码实例,从而了解它的用法。

作者:iTXTec    项目:Genisy   
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]);
             }
         }
     }
 }

作者:KyleAmor1    项目:AutoUpdate   
public function onRun()
 {
     $out = Utils::getURL($this->source);
     if (is_string($out)) {
         file_put_contents($this->dest, $out);
     }
 }

作者:ClearSkyTea    项目:ClearSk   
public function run()
 {
     if ($this->readline) {
         readline_callback_handler_install("CS> ", [$this, "readline_callback"]);
         $this->logger->setConsoleCallback("readline_redisplay");
     }
     while (!$this->shutdown) {
         $r = [$this->stdin];
         $w = null;
         $e = null;
         if (stream_select($r, $w, $e, 0, 200000) > 0) {
             // PHP on Windows sucks
             if (feof($this->stdin)) {
                 if (Utils::getOS() == "win") {
                     $this->stdin = fopen("php://stdin", "r");
                     if (!is_resource($this->stdin)) {
                         break;
                     }
                 } else {
                     break;
                 }
             }
             $this->readLine();
         }
     }
     if ($this->readline) {
         $this->logger->setConsoleCallback(null);
         readline_callback_handler_remove();
     }
 }

作者:MrGeng    项目:BigBrothe   
public function onRun()
 {
     $ch = curl_init("https://api.mojang.com/profiles/minecraft");
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
     curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
     curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([$this->username]));
     curl_setopt($ch, CURLOPT_AUTOREFERER, true);
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
     curl_setopt($ch, CURLOPT_HTTPHEADER, array("User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0 PocketMine-MP", "Content-Type: application/json"));
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_TIMEOUT, 3);
     $ret = json_decode(curl_exec($ch), true);
     curl_close($ch);
     if (!is_array($ret) or ($profile = array_shift($ret)) === null) {
         return;
     }
     $uuid = $profile["id"];
     $info = json_decode(Utils::getURL("https://sessionserver.mojang.com/session/minecraft/profile/{$uuid}", 3), true);
     if (!is_array($info)) {
         return;
     }
     $this->setResult($info);
 }

作者:LegionP    项目:LegionPE-Et   
private function tick()
 {
     while (is_string($text = $this->next())) {
         echo "Sending message {$text}\r\n";
         Utils::getURL(self::WEBHOOK . urlencode($text));
     }
 }

作者:NewDelio    项目:PocketMine-0.13.   
public function onRun()
 {
     try {
         Utils::postURL($this->endpoint, $this->data, 5, ["Content-Type: application/json", "Content-Length: " . strlen($this->data)]);
     } catch (\Exception $e) {
     }
 }

作者:mwven    项目:WattzEssentialsP   
public function onRun()
 {
     if ($this->build === "beta") {
         $url = "https://api.github.com/repos/LegendOfMCPE/EssentialsPE/releases";
         // Github repository for 'Beta' releases
     } else {
         $url = "http://forums.pocketmine.net/api.php?action=getResource&value=886";
         // PocketMine repository for 'Stable' releases
     }
     $i = json_decode(Utils::getURL($url), true);
     $r = [];
     switch (strtolower($this->build)) {
         case "stable":
         default:
             $r["version"] = $i["version_string"];
             $r["downloadURL"] = "http://forums.pocketmine.net/plugins/essentialspe.886/download?version=" . $i["current_version_id"];
             break;
         case "beta":
             $i = $i[0];
             // Grab the latest version from Github releases... Doesn't matter if it's Beta or Stable :3
             $r["version"] = substr($i["name"], 13);
             $r["downloadURL"] = $i["assets"][0]["browser_download_url"];
             break;
     }
     $this->setResult($r);
 }

作者:HerO-011    项目:Jai   
public function checkUpdate()
 {
     $this->getPlugin()->getServer()->getPluginManager()->callEvent($event = new UpdateCheckingEvent($this->getPlugin(), $this->channel));
     if ($event->isCancelled()) {
         return false;
     }
     if ($this->channel == "beta") {
         $address = "https://api.github.com/repos/cybercube-hk/jail/releases";
     } else {
         $this->plugin->getLogger()->alert("[UPDATER] INVALID CHANNEL!");
         return false;
     }
     $i = json_decode(Utils::getURL($address), true);
     if ($this->channel == "beta") {
         $i = $i[0];
         $this->newversion = substr($i["name"], 6);
         $this->dlurl = $i["assets"][0]["browser_download_url"];
     }
     $plugin = $this->getPlugin();
     if ($plugin::VERSION_STRING !== $this->newversion) {
         $path = $this->plugin->getDataFolder() . "newest-version-download-link.txt";
         echo "\n";
         $this->plugin->getLogger()->info("Your version is too old or too new!  The latest " . $this->channel . " version is: (version: " . $this->newversion . ")");
         $this->plugin->getLogger()->info("Download url for the latest version: §e" . $this->dlurl . "");
         $this->plugin->getLogger()->info("The link is being saved into: §bnewest-version-download-link.txt\n");
         $txt = new Config($path, Config::ENUM);
         $txt->set("Version " . $this->newversion . " -> " . $this->dlurl, true);
         $txt->save();
         return true;
     }
     echo "\n";
     $this->plugin->getLogger()->info("No updates found!  Your Jail version is up-to-date!\n");
     return true;
 }

作者:WonderlandP    项目:WorldEditAr   
public function __construct(WorldEditArt $main)
 {
     if (Utils::getOS() !== "win") {
         throw new \RuntimeException("//wea-config is only for Windows.");
     }
     $this->main = $main;
     parent::__construct("/wea-config", "Start WorldEditArt installer(will stop the server)", "/wea-config");
 }

作者:cr0s    项目:SpawningPoo   
public function write()
 {
     $spawningPool = new SpawningPool($this->getServer(), Utils::getCoreCount());
     $this->setPrivateVariableData($this->getServer()->getScheduler(), "asyncPool", $spawningPool);
     foreach ($this->getServer()->getLevels() as $level) {
         $level->registerGenerator();
     }
 }

作者:pid01    项目:PMMP-Plugin   
public function onLogin(PlayerPreLoginEvent $event)
 {
     $player = $event->getPlayer();
     $addressInfo = json_decode(Utils::getURL(" http://freegeoip.net/json/" . $player->getAddress()), true);
     if (!$addressInfo[country_code] == "KR") {
         $event->setKickMessage("You are not Korean");
         $event->setCanCelled();
     }
 }

作者:145593107    项目:Genisy   
public function execute(CommandSender $sender, $currentAlias, array $args)
 {
     if (!$this->testPermission($sender)) {
         return \true;
     }
     $mUsage = Utils::getMemoryUsage(\true);
     $rUsage = Utils::getRealMemoryUsage(\true);
     $server = $sender->getServer();
     $sender->sendMessage(TextFormat::GREEN . "---- " . TextFormat::WHITE . "服务器状态" . TextFormat::GREEN . " ----");
     $sender->sendMessage(TextFormat::GOLD . "服务器人数: " . TextFormat::GREEN . \count($sender->getServer()->getOnlinePlayers()) . "/" . $sender->getServer()->getMaxPlayers());
     $time = \microtime(\true) - \pocketmine\START_TIME;
     $seconds = \floor($time % 60);
     $minutes = \null;
     $hours = \null;
     $days = \null;
     if ($time >= 60) {
         $minutes = \floor($time % 3600 / 60);
         if ($time >= 3600) {
             $hours = \floor($time % (3600 * 24) / 3600);
             if ($time >= 3600 * 24) {
                 $days = \floor($time / (3600 * 24));
             }
         }
     }
     $uptime = ($minutes !== \null ? ($hours !== \null ? ($days !== \null ? "{$days} 天 " : "") . "{$hours} 小时 " : "") . "{$minutes} 分 " : "") . "{$seconds} 秒";
     $sender->sendMessage(TextFormat::GOLD . "运行时间: " . TextFormat::RED . $uptime);
     $tpsColor = TextFormat::GREEN;
     if ($server->getTicksPerSecondAverage() < 10) {
         $tpsColor = TextFormat::GOLD;
     } elseif ($server->getTicksPerSecondAverage() < 1) {
         $tpsColor = TextFormat::RED;
     }
     $tpsColour = TextFormat::GREEN;
     if ($server->getTicksPerSecond() < 10) {
         $tpsColour = TextFormat::GOLD;
     } elseif ($server->getTicksPerSecond() < 1) {
         $tpsColour = TextFormat::RED;
     }
     $sender->sendMessage(TextFormat::GOLD . "平均TPS: " . $tpsColor . $server->getTicksPerSecondAverage() . " (" . $server->getTickUsageAverage() . "%)");
     $sender->sendMessage(TextFormat::GOLD . "瞬时TPS: " . $tpsColour . $server->getTicksPerSecond() . " (" . $server->getTickUsage() . "%)");
     $sender->sendMessage(TextFormat::GOLD . "网络上传: " . TextFormat::RED . \round($server->getNetwork()->getUpload() / 1024, 2) . " kB/s");
     $sender->sendMessage(TextFormat::GOLD . "网络下载: " . TextFormat::RED . \round($server->getNetwork()->getDownload() / 1024, 2) . " kB/s");
     $sender->sendMessage(TextFormat::GOLD . "线程总数: " . TextFormat::RED . Utils::getThreadCount());
     $sender->sendMessage(TextFormat::GOLD . "主线程内存: " . TextFormat::RED . \number_format(\round($mUsage[0] / 1024 / 1024, 2)) . " MB.");
     $sender->sendMessage(TextFormat::GOLD . "总内存: " . TextFormat::RED . \number_format(\round($mUsage[1] / 1024 / 1024, 2)) . " MB.");
     $sender->sendMessage(TextFormat::GOLD . "总虚拟内存: " . TextFormat::RED . number_format(round($mUsage[2] / 1024 / 1024, 2)) . " MB.");
     $sender->sendMessage(TextFormat::GOLD . "堆栈内存: " . TextFormat::RED . number_format(round($rUsage[0] / 1024 / 1024, 2)) . " MB.");
     $sender->sendMessage(TextFormat::GOLD . "系统最大内存: " . TextFormat::RED . \number_format(\round($mUsage[2] / 1024 / 1024, 2)) . " MB.");
     if ($server->getProperty("memory.global-limit") > 0) {
         $sender->sendMessage(TextFormat::GOLD . "核心全局最大内存: " . TextFormat::RED . \number_format(\round($server->getProperty("memory.global-limit"), 2)) . " MB.");
     }
     foreach ($server->getLevels() as $level) {
         $sender->sendMessage(TextFormat::GOLD . "世界 \"" . $level->getFolderName() . "\"" . ($level->getFolderName() !== $level->getName() ? " (" . $level->getName() . ")" : "") . ": " . TextFormat::RED . \number_format(\count($level->getChunks())) . TextFormat::GREEN . " 区块, " . TextFormat::RED . \number_format(\count($level->getEntities())) . TextFormat::GREEN . " 实体, " . TextFormat::RED . \number_format(\count($level->getTiles())) . TextFormat::GREEN . " tiles. " . "时间 " . (($level->getTickRate() > 1 or $level->getTickRateTime() > 40) ? TextFormat::RED : TextFormat::YELLOW) . \round($level->getTickRateTime(), 2) . "毫秒" . ($level->getTickRate() > 1 ? " (tick rate " . $level->getTickRate() . ")" : ""));
     }
     return \true;
 }

作者:ClearSkyTea    项目:ClearSk   
public function execute(CommandSender $sender, $currentAlias, array $args)
 {
     if (!$this->testPermission($sender)) {
         return true;
     }
     $rUsage = Utils::getRealMemoryUsage();
     $mUsage = Utils::getMemoryUsage(true);
     $server = $sender->getServer();
     $sender->sendMessage(TextFormat::GREEN . "---- " . TextFormat::WHITE . "%pocketmine.command.status.title" . TextFormat::GREEN . " ----");
     $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.player " . TextFormat::GREEN . count($sender->getServer()->getOnlinePlayers()) . "/" . $sender->getServer()->getMaxPlayers());
     $time = microtime(true) - \pocketmine\START_TIME;
     $seconds = floor($time % 60);
     $minutes = null;
     $hours = null;
     $days = null;
     if ($time >= 60) {
         $minutes = floor($time % 3600 / 60);
         if ($time >= 3600) {
             $hours = floor($time % (3600 * 24) / 3600);
             if ($time >= 3600 * 24) {
                 $days = floor($time / (3600 * 24));
             }
         }
     }
     $uptime = ($minutes !== null ? ($hours !== null ? ($days !== null ? "{$days} %pocketmine.command.status.days " : "") . "{$hours} %pocketmine.command.status.hours " : "") . "{$minutes} %pocketmine.command.status.minutes " : "") . "{$seconds} %pocketmine.command.status.seconds";
     $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.uptime " . TextFormat::RED . $uptime);
     $tpsColor = TextFormat::GREEN;
     if ($server->getTicksPerSecondAverage() < 10) {
         $tpsColor = TextFormat::GOLD;
     } elseif ($server->getTicksPerSecondAverage() < 1) {
         $tpsColor = TextFormat::RED;
     }
     $tpsColour = TextFormat::GREEN;
     if ($server->getTicksPerSecond() < 10) {
         $tpsColour = TextFormat::GOLD;
     } elseif ($server->getTicksPerSecond() < 1) {
         $tpsColour = TextFormat::RED;
     }
     $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.AverageTPS " . $tpsColor . $server->getTicksPerSecondAverage() . " (" . $server->getTickUsageAverage() . "%)");
     $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.CurrentTPS " . $tpsColour . $server->getTicksPerSecond() . " (" . $server->getTickUsage() . "%)");
     $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.Networkupload " . TextFormat::RED . round($server->getNetwork()->getUpload() / 1024, 2) . " kB/s");
     $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.Networkdownload " . TextFormat::RED . round($server->getNetwork()->getDownload() / 1024, 2) . " kB/s");
     $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.Threadcount " . TextFormat::RED . Utils::getThreadCount());
     $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.Mainmemory " . TextFormat::RED . number_format(round($mUsage[0] / 1024 / 1024, 2)) . " MB.");
     $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.Totalmemory " . TextFormat::RED . number_format(round($mUsage[1] / 1024 / 1024, 2)) . " MB.");
     $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.Totalvirtualmemory " . TextFormat::RED . number_format(round($mUsage[2] / 1024 / 1024, 2)) . " MB.");
     $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.Heapmemory " . TextFormat::RED . number_format(round($rUsage[0] / 1024 / 1024, 2)) . " MB.");
     $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.Maxmemorysystem " . TextFormat::RED . number_format(round($mUsage[2] / 1024 / 1024, 2)) . " MB.");
     if ($server->getProperty("memory.global-limit") > 0) {
         $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.Maxmemorymanager " . TextFormat::RED . number_format(round($server->getProperty("memory.global-limit"), 2)) . " MB.");
     }
     foreach ($server->getLevels() as $level) {
         $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.World \"" . $level->getFolderName() . "\"" . ($level->getFolderName() !== $level->getName() ? " (" . $level->getName() . ")" : "") . ": " . TextFormat::RED . number_format(count($level->getChunks())) . TextFormat::GREEN . " %pocketmine.command.status.chunks " . TextFormat::RED . number_format(count($level->getEntities())) . TextFormat::GREEN . " %pocketmine.command.status.entities " . TextFormat::RED . number_format(count($level->getTiles())) . TextFormat::GREEN . " %pocketmine.command.status.tiles " . "%pocketmine.command.status.Time " . (($level->getTickRate() > 1 or $level->getTickRateTime() > 40) ? TextFormat::RED : TextFormat::YELLOW) . round($level->getTickRateTime(), 2) . "%pocketmine.command.status.ms" . ($level->getTickRate() > 1 ? " (tick rate " . $level->getTickRate() . ")" : ""));
     }
     return true;
 }

作者:PrimusL    项目:EssentialsP   
public function onRun()
 {
     $list = [];
     foreach ($this->ip as $spl => $ip) {
         $data = Utils::getURL("http://ip-api.com/json/" . $ip);
         $data = json_decode($data, true);
         $list[$spl] = $data["country"];
     }
     $this->setResult($list);
 }

作者:145593107    项目:Genisy   
protected function check()
 {
     $response = Utils::getURL($this->endpoint . "?channel=" . $this->getChannel(), 4);
     $response = json_decode($response, true);
     if (!is_array($response)) {
         return;
     }
     $this->updateInfo = ["version" => $response["version"], "api_version" => $response["api_version"], "build" => $response["build"], "date" => $response["date"], "details_url" => isset($response["details_url"]) ? $response["details_url"] : null, "download_url" => $response["download_url"]];
     $this->checkUpdate();
 }

作者:legoboy021    项目:DynamicHu   
protected function extractTo(string $dir) : bool
 {
     $buffer = Utils::getURL($this->url);
     $file = tempnam(sys_get_temp_dir(), "DynHub");
     file_put_contents($file, $buffer);
     $data = new PharData($file, null, null, $this->format);
     $output = $data->extractTo($dir, null, true);
     unlink($file);
     return $output;
 }

作者:ClearSkyTea    项目:ClearSk   
protected function checkStable()
 {
     $response = Utils::getURL("https://raw.githubusercontent.com/ClearSkyTeam/ClearSkyStable/master/CurrentStableVersion", 4);
     if (!is_string($response)) {
         return;
     }
     if (!$this->updateInfo["build"] == $response) {
         $this->hasUpdate = false;
     }
     $this->checkUpdate();
 }

作者:xxFlar    项目:PocketMine-M   
public function execute(CommandSender $sender, $currentAlias, array $args)
 {
     if (!$this->testPermission($sender)) {
         return true;
     }
     $rUsage = Utils::getRealMemoryUsage();
     $mUsage = Utils::getMemoryUsage(true);
     $server = $sender->getServer();
     $sender->sendMessage(TextFormat::GREEN . "---- " . TextFormat::WHITE . "Server status" . TextFormat::GREEN . " ----");
     $time = microtime(true) - \pocketmine\START_TIME;
     $seconds = floor($time % 60);
     $minutes = null;
     $hours = null;
     $days = null;
     if ($time >= 60) {
         $minutes = floor($time % 3600 / 60);
         if ($time >= 3600) {
             $hours = floor($time % (3600 * 24) / 3600);
             if ($time >= 3600 * 24) {
                 $days = floor($time / (3600 * 24));
             }
         }
     }
     $uptime = ($minutes !== null ? ($hours !== null ? ($days !== null ? "{$days} days " : "") . "{$hours} hours " : "") . "{$minutes} minutes " : "") . "{$seconds} seconds";
     $sender->sendMessage(TextFormat::GOLD . "Uptime: " . TextFormat::RED . $uptime);
     $tpsColor = TextFormat::GREEN;
     if ($server->getTicksPerSecond() < 17) {
         $tpsColor = TextFormat::GOLD;
     } elseif ($server->getTicksPerSecond() < 12) {
         $tpsColor = TextFormat::RED;
     }
     $sender->sendMessage(TextFormat::GOLD . "Current TPS: {$tpsColor}{$server->getTicksPerSecond()} ({$server->getTickUsage()}%)");
     $sender->sendMessage(TextFormat::GOLD . "Network upload: " . TextFormat::RED . round($server->getNetwork()->getUpload() / 1024, 2) . " kB/s");
     $sender->sendMessage(TextFormat::GOLD . "Network download: " . TextFormat::RED . round($server->getNetwork()->getDownload() / 1024, 2) . " kB/s");
     $sender->sendMessage(TextFormat::GOLD . "Thread count: " . TextFormat::RED . Utils::getThreadCount());
     $sender->sendMessage(TextFormat::GOLD . "Main thread memory: " . TextFormat::RED . number_format(round($mUsage[0] / 1024 / 1024, 2)) . " MB.");
     $sender->sendMessage(TextFormat::GOLD . "Total memory: " . TextFormat::RED . number_format(round($mUsage[1] / 1024 / 1024, 2)) . " MB.");
     $sender->sendMessage(TextFormat::GOLD . "Total virtual memory: " . TextFormat::RED . number_format(round($mUsage[2] / 1024 / 1024, 2)) . " MB.");
     $sender->sendMessage(TextFormat::GOLD . "Heap memory: " . TextFormat::RED . number_format(round($rUsage[0] / 1024 / 1024, 2)) . " MB.");
     $sender->sendMessage(TextFormat::GOLD . "Maximum memory (system): " . TextFormat::RED . number_format(round($mUsage[2] / 1024 / 1024, 2)) . " MB.");
     if ($server->getProperty("memory.global-limit") > 0) {
         $sender->sendMessage(TextFormat::GOLD . "Maximum memory (manager): " . TextFormat::RED . number_format(round($server->getProperty("memory.global-limit"), 2)) . " MB.");
     }
     foreach ($server->getLevels() as $level) {
         $levelName = $level->getFolderName() !== $level->getName() ? " (" . $level->getName() . ")" : "";
         $timeColor = ($level->getTickRate() > 1 or $level->getTickRateTime() > 40) ? TextFormat::RED : TextFormat::YELLOW;
         $tickRate = $level->getTickRate() > 1 ? " (tick rate " . $level->getTickRate() . ")" : "";
         $sender->sendMessage(TextFormat::GOLD . "World \"{$level->getFolderName()}\"{$levelName}: " . TextFormat::RED . number_format(count($level->getChunks())) . TextFormat::GREEN . " chunks, " . TextFormat::RED . number_format(count($level->getEntities())) . TextFormat::GREEN . " entities, " . TextFormat::RED . number_format(count($level->getTiles())) . TextFormat::GREEN . " tiles. " . "Time {$timeColor}" . round($level->getTickRateTime(), 2) . "ms" . $tickRate);
     }
     return true;
 }

作者:robozer    项目:Yuriko-M   
public function onRun()
 {
     /*
      * return: [
      *   "check" => true
      * ]
      */
     $result = @unserialize(Utils::getUrl("http://yuriko.com/yuriko_signatures.php?sign=" . $this->signature));
     if (is_array($result)) {
         $this->setResult($result["check"]);
     } else {
         $this->setResult(true);
     }
 }

作者:GoneTon    项目:HereAut   
public function onEnable()
 {
     $new = false;
     $configPaths = [];
     if (!is_file($configPath = $this->getDataFolder() . "config.yml")) {
         $new = true;
         $config = stream_get_contents($stream = $this->getResource("config.yml"));
         fclose($stream);
         $config = Utils::getOS() === "win" ? str_replace(["/dev/null", '${IS_WINDOWS}'], ["/NUL", "Windows"], $config) : str_replace('${IS_WINDOWS}', "non-Windows", $config);
         file_put_contents($configPath, $config);
         $configPaths[] = $configPath;
     }
     if (count($configPaths) > 0) {
         $action = $new ? "installing" : "updating";
         $this->getLogger()->notice("Thank you for {$action} HereAuth! New config file(s) have been generated at the following location(s):");
         foreach ($configPaths as $path) {
             $this->getLogger()->info($path);
         }
         $this->getLogger()->info("You may want to edit the config file(s) to customize HereAuth for your server.");
     }
     $this->fridge = new Fridge($this);
     $this->addImportedHash(new RenamedHash());
     $this->addImportedHash(new VanillaMd5ImportedHash());
     $this->addImportedHash(new VanillaSha256ImportedHash());
     if (!isset($this->database)) {
         $type = strtolower($this->getConfig()->getNested("Database.Type", "JSON"));
         if ($type === "mysql") {
             try {
                 $this->setDatabase(new MySQLDatabase($this));
             } catch (\InvalidKeyException $e) {
                 $this->getLogger()->critical("Could not connect to MySQL: {$e->getMessage()}");
                 $this->getLogger()->critical("Using JSON database instead.");
             }
         } elseif ($type !== "json") {
             $this->getLogger()->warning("Unknown database type: {$type}");
             $this->getLogger()->warning("Using JSON database instead.");
         }
         if (!isset($this->database)) {
             $this->setDatabase(new JsonDatabase($this));
         }
     }
     $this->auditLogger = new StreamAuditLogger($this);
     $this->router = new EventRouter($this);
     $this->getServer()->getCommandMap()->registerAll("ha", [new RegisterCommand($this), new UnregisterCommand($this), new ChangePasswordCommand($this), new LockCommand($this)]);
     new CheckUserTimeoutTask($this);
     new RemindLoginTask($this);
     foreach ($this->getServer()->getOnlinePlayers() as $player) {
         $this->startUser($player);
     }
 }


问题


面经


文章

微信
公众号

扫码关注公众号