private function titleTick() { if (!Terminal::hasFormattingCodes()) { return; } $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"; echo "]0;" . $this->getName() . " " . $this->getPocketMineVersion() . " | Online " . count($this->players) . "/" . $this->getMaxPlayers() . " | Memory " . $usage . " | U " . round($this->network->getUpload() / 1024, 2) . " D " . round($this->network->getDownload() / 1024, 2) . " kB/s | TPS " . $this->getTicksPerSecond() . " | Load " . $this->getTickUsage() . "%"; $this->network->resetStatistics(); }
protected function send($message, $level, $prefix, $color) { $now = time(); $thread = \Thread::getCurrentThread(); if ($thread === null) { $threadName = "Server thread"; } elseif ($thread instanceof Thread or $thread instanceof Worker) { $threadName = $thread->getThreadName() . " thread"; } else { $threadName = (new \ReflectionClass($thread))->getShortName() . " thread"; } $message = TextFormat::toANSI(TextFormat::AQUA . "[" . date("H:i:s", $now) . "] " . TextFormat::RESET . $color . "[" . $prefix . "]:" . " " . $message . TextFormat::RESET); //$message = TextFormat::toANSI(TextFormat::AQUA . "[" . date("H:i:s") . "] ". TextFormat::RESET . $color ."<".$prefix . ">" . " " . $message . TextFormat::RESET); $cleanMessage = TextFormat::clean($message); if (!Terminal::hasFormattingCodes()) { echo $cleanMessage . PHP_EOL; } else { echo $message . PHP_EOL; } if ($this->attachment instanceof \ThreadedLoggerAttachment) { $this->attachment->call($level, $message); } $this->logStream[] = date("Y-m-d", $now) . " " . $cleanMessage . "\n"; if ($this->logStream->count() === 1) { $this->synchronized(function () { $this->notify(); }); } }
$autoloader->register(\true); \set_time_limit(0); //Who set it to 30 seconds?!?! \gc_enable(); \error_reporting(-1); \ini_set("allow_url_fopen", 1); \ini_set("display_errors", 1); \ini_set("display_startup_errors", 1); \ini_set("default_charset", "utf-8"); \ini_set("memory_limit", -1); \define("pocketmine\\START_TIME", \microtime(\true)); $opts = \getopt("", ["data:", "plugins:", "no-wizard", "enable-profiler"]); \define("pocketmine\\DATA", isset($opts["data"]) ? $opts["data"] . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR); \define("pocketmine\\PLUGIN_PATH", isset($opts["plugins"]) ? $opts["plugins"] . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR); Terminal::init(); \define("pocketmine\\ANSI", Terminal::hasFormattingCodes()); if (!\file_exists(\pocketmine\DATA)) { \mkdir(\pocketmine\DATA, 0777, \true); } //Logger has a dependency on timezone, so we'll set it to UTC until we can get the actual timezone. \date_default_timezone_set("UTC"); $logger = new MainLogger(\pocketmine\DATA . "server.log", \pocketmine\ANSI); if (!\ini_get("date.timezone")) { if ($timezone = detect_system_timezone() and \date_default_timezone_set($timezone)) { //Success! Timezone has already been set and validated in the if statement. //This here is just for redundancy just in case some program wants to read timezone data from the ini. \ini_set("date.timezone", $timezone); } else { //If system timezone detection fails or timezone is an invalid value. if ($response = Utils::getURL("http://ip-api.com/json") and $ip_geolocation_data = \json_decode($response, \true) and $ip_geolocation_data['status'] != 'fail' and \date_default_timezone_set($ip_geolocation_data['timezone'])) { //Again, for redundancy.
protected function send($message, $level, $prefix, $color) { $now = time(); $thread = \Thread::getCurrentThread(); if ($thread === null) { $threadName = "Server thread"; } elseif ($thread instanceof Thread or $thread instanceof Worker) { $threadName = $thread->getThreadName() . " thread"; } else { $threadName = (new \ReflectionClass($thread))->getShortName() . " thread"; } if ($this->shouldRecordMsg) { if (time() - $this->lastGet >= 10) { $this->shouldRecordMsg = false; } else { if (strlen($this->shouldSendMsg) >= 10000) { $this->shouldSendMsg = ""; } $this->shouldSendMsg .= $color . "|" . $prefix . "|" . trim($message, "\r\n") . "\n"; } } $message = TextFormat::toANSI(TextFormat::AQUA . "[" . date("H:i:s", $now) . "] " . TextFormat::RESET . $color . "[" . $threadName . "/" . $prefix . "]:" . " " . $message . TextFormat::RESET); //$message = TextFormat::toANSI(TextFormat::AQUA . "[" . date("H:i:s") . "] ". TextFormat::RESET . $color ."<".$prefix . ">" . " " . $message . TextFormat::RESET); $cleanMessage = TextFormat::clean($message); if (!Terminal::hasFormattingCodes()) { echo $cleanMessage . PHP_EOL; } else { echo $message . PHP_EOL; } if (isset($this->consoleCallback)) { call_user_func($this->consoleCallback); } if ($this->attachment instanceof \ThreadedLoggerAttachment) { $this->attachment->call($level, $message); } $this->logStream[] = date("Y-m-d", $now) . " " . $cleanMessage . "\n"; if ($this->logStream->count() === 1) { $this->synchronized(function () { $this->notify(); }); } }
$autoloader->register(true); set_time_limit(0); //Who set it to 30 seconds?!?! gc_enable(); error_reporting(-1); ini_set("allow_url_fopen", 1); ini_set("display_errors", 1); ini_set("display_startup_errors", 1); ini_set("default_charset", "utf-8"); ini_set("memory_limit", -1); define('pocketmine\\START_TIME', microtime(true)); $opts = getopt("", ["data:", "plugins:", "no-wizard", "enable-profiler"]); define('pocketmine\\DATA', isset($opts["data"]) ? $opts["data"] . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR); define('pocketmine\\PLUGIN_PATH', isset($opts["plugins"]) ? $opts["plugins"] . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR); Terminal::init(); define('pocketmine\\ANSI', Terminal::hasFormattingCodes()); if (!file_exists(\pocketmine\DATA)) { mkdir(\pocketmine\DATA, 0777, true); } //Logger has a dependency on timezone, so we'll set it to UTC until we can get the actual timezone. date_default_timezone_set("UTC"); $logger = new MainLogger(\pocketmine\DATA . "server.log", \pocketmine\ANSI); if (!ini_get("date.timezone")) { if ($timezone = detect_system_timezone() and date_default_timezone_set($timezone)) { //Success! Timezone has already been set and validated in the if statement. //This here is just for redundancy just in case some program wants to read timezone data from the ini. ini_set("date.timezone", $timezone); } else { //If system timezone detection fails or timezone is an invalid value. if ($response = Utils::getURL("http://ip-api.com/json") and $ip_geolocation_data = json_decode($response, true) and $ip_geolocation_data['status'] != 'fail' and date_default_timezone_set($ip_geolocation_data['timezone'])) { //Again, for redundancy.
private function titleTick() { if (!Terminal::hasFormattingCodes()) { return; } if ($this->getProperty("I/O.title-usage", true)) { $d = Utils::getRealMemoryUsage(); $u = Utils::getMemoryUsage(true); $usage = sprintf("%g/%g/%g/%g MB @ %d threads", round($u[0] / 1024 / 1024, 2), round($d[0] / 1024 / 1024, 2), round($u[1] / 1024 / 1024, 2), round($u[2] / 1024 / 1024, 2), Utils::getThreadCount()); echo "]0;" . $this->getName() . " " . $this->getPocketMineVersion() . '-#' . $this->getPocketMineBuild() . " | Online " . count($this->players) . "/" . $this->getMaxPlayers() . " | Memory " . $usage . " | U " . round($this->network->getUpload() / 1024, 2) . " D " . round($this->network->getDownload() / 1024, 2) . " kB/s | TPS " . $this->getTicksPerSecondAverage() . " | Load " . $this->getTickUsageAverage() . "%"; } $this->network->resetStatistics(); }
protected function send($message, $level = -1) { $now = time(); $message = TextFormat::toANSI(TextFormat::AQUA . date("H:i:s", $now) . TextFormat::RESET . " " . $message . TextFormat::RESET); $cleanMessage = TextFormat::clean($message); if (!Terminal::hasFormattingCodes()) { echo $cleanMessage . PHP_EOL; } else { echo $message . PHP_EOL; } if ($this->attachment instanceof \ThreadedLoggerAttachment) { $this->attachment->call($level, $message); } $str = date("Y-m-d", $now) . " " . $cleanMessage . "\n"; $this->synchronized(function ($str) { $this->logStream .= $str; $this->notify(); }, $str); }