本文整理汇总了PHP中pocketmine\Server::getLogger方法的典型用法代码示例。如果您正苦于以下问题:PHP Server::getLogger方法的具体用法?PHP Server::getLogger怎么用?PHP Server::getLogger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\Server
的用法示例。
在下文中一共展示了Server::getLogger方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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]);
}
}
}
}
示例2: __construct
public function __construct(Server $server, $password, $port = 19132, $interface = "0.0.0.0", $threads = 1, $clientsPerThread = 50)
{
$this->server = $server;
$this->workers = [];
$this->password = (string) $password;
$this->server->getKatana()->console->system("Starting remote control listener", "debug");
if ($this->password === "") {
$this->server->getLogger()->critical("RCON can't be started: Empty password");
return;
}
$this->threads = (int) max(1, $threads);
$this->clientsPerThread = (int) max(1, $clientsPerThread);
$this->socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if ($this->socket === false or !socket_bind($this->socket, $interface, (int) $port) or !socket_listen($this->socket)) {
$this->server->getLogger()->critical("RCON can't be started: " . socket_strerror(socket_last_error()));
$this->threads = 0;
return;
}
socket_set_block($this->socket);
for ($n = 0; $n < $this->threads; ++$n) {
$this->workers[$n] = new RCONInstance($this->socket, $this->password, $this->clientsPerThread);
}
socket_getsockname($this->socket, $addr, $port);
$this->server->getKatana()->console->system("RCON running on {$addr}:{$port}");
}
示例3: 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]);
}
}
}
}
示例4: processBatch
public function processBatch(BatchPacket $packet, Player $p)
{
$str = \zlib_decode($packet->payload, 1024 * 1024 * 64);
//Max 64MB
$len = strlen($str);
$offset = 0;
try {
while ($offset < $len) {
if (($pk = $this->getPacket(ord($str[$offset++]))) !== null) {
if ($pk::NETWORK_ID === Info::BATCH_PACKET) {
throw new \InvalidStateException("Invalid BatchPacket inside BatchPacket");
}
$pk->setBuffer($str, $offset);
$pk->decode();
$p->handleDataPacket($pk);
$offset += $pk->getOffset();
if ($pk->getOffset() <= 0) {
return;
}
}
}
} catch (\Exception $e) {
if (\pocketmine\DEBUG > 1) {
$logger = $this->server->getLogger();
if ($logger instanceof MainLogger) {
$logger->debug("BatchPacket " . " 0x" . bin2hex($packet->payload));
$logger->logException($e);
}
}
}
}
示例5: onCompletion
public function onCompletion(Server $server)
{
$plugin = $server->getPluginManager()->getPlugin($this->owner);
if ($plugin == null) {
$server->getLogger()->error("Internal ERROR: " . __METHOD__ . "," . __LINE__);
return;
}
if (!$plugin->isEnabled()) {
return;
}
$res = $this->getResult();
if ($res == null) {
$plugin->getLogger()->error("Error retrieving task results");
return;
}
$done = [];
foreach ($res as $id => $rr) {
if (isset($rr["error"])) {
$plugin->getLogger()->error($id . ": " . $rr["error"]);
} else {
$done[$id] = $rr["content"];
}
}
$plugin->retrieveDone($done);
if ($plugin->debug) {
$plugin->getLogger()->debug("FetchTask completed.");
}
}
示例6: findFiles
protected function findFiles($zip, $file, $warnphar = false)
{
$files = [];
$za = new \ZipArchive();
if ($za->open($zip) !== true) {
return null;
}
// Look for plugin data...
$basepath = null;
for ($i = 0; $i < $za->numFiles; $i++) {
$st = $za->statIndex($i);
if (!isset($st["name"])) {
continue;
}
if (basename($st["name"]) == $file) {
$files[] = $st["name"];
continue;
}
if (preg_match('/\\.phar$/i', $st["name"])) {
$this->server->getLogger()->warning("[ZipPluginLoader] Skipping PHAR file: " . $st["name"]);
}
}
$za->close();
unset($za);
if (count($files)) {
return $files;
}
return null;
}
示例7: handleEncapsulated
public function handleEncapsulated($identifier, EncapsulatedPacket $packet, $flags)
{
if (isset($this->players[$identifier])) {
try {
if ($packet->buffer !== "") {
$pk = $this->getPacket($packet->buffer);
if ($pk !== null) {
$pk->decode();
if ($pk::NETWORK_ID == ProtocolInfo::LOGIN_PACKET) {
$pk->protocol1 = 38;
}
$this->players[$identifier]->handleDataPacket($pk);
}
}
} catch (\Throwable $e) {
if (\pocketmine\DEBUG > 1 and isset($pk)) {
$logger = $this->server->getLogger();
$logger->debug("Packet " . get_class($pk) . " 0x" . bin2hex($packet->buffer));
$logger->logException($e);
}
if (isset($this->players[$identifier])) {
$this->interface->blockAddress($this->players[$identifier]->getAddress(), 5);
}
}
}
}
示例8: __construct
public function __construct($server)
{
$this->server = $server;
$this->logger = $this->server->getLogger();
$this->logger->info(Terminal::$COLOR_GOLD . "-------------------------------------------------------------------------------------------");
$this->logger->info(Terminal::$COLOR_GOLD . "|" . Terminal::$COLOR_PURPLE . " _ _ _" . Terminal::$COLOR_AQUA . " __ __ _ " . Terminal::$COLOR_GOLD . " |");
$this->logger->info(Terminal::$COLOR_GOLD . "|" . Terminal::$COLOR_PURPLE . " (_) (_) | |" . Terminal::$COLOR_AQUA . " \\/ (_) " . Terminal::$COLOR_GOLD . " |");
$this->logger->info(Terminal::$COLOR_GOLD . "|" . Terminal::$COLOR_PURPLE . " _ _ __ ___ __ _ __ _ _ ___ __ _| |" . Terminal::$COLOR_AQUA . " \\ / |_ _ __ ___ " . Terminal::$COLOR_GOLD . " |");
$this->logger->info(Terminal::$COLOR_GOLD . "|" . Terminal::$COLOR_PURPLE . " | | '_ ` _ \\ / _` |/ _` | |/ __/ _` | |" . Terminal::$COLOR_AQUA . " |\\/| | | '_ \\ / _ \\ " . Terminal::$COLOR_RED . " ImagicalMine " . $this->server->getPocketMineVersion() . Terminal::$COLOR_GOLD . " |");
$this->logger->info(Terminal::$COLOR_GOLD . "|" . Terminal::$COLOR_PURPLE . " | | | | | | | (_| | (_| | | (_| (_| | |" . Terminal::$COLOR_AQUA . " | | | | | | | __/ " . Terminal::$COLOR_GOLD . " |");
$this->logger->info(Terminal::$COLOR_GOLD . "|" . Terminal::$COLOR_PURPLE . " |_|_| |_| |_|\\__,_|\\__, |_|\\___\\__,_|_|" . Terminal::$COLOR_AQUA . "_| |_|_|_| |_|\\___| " . Terminal::$COLOR_WHITE . " for MCPE " . $this->server->getVersion() . Terminal::$COLOR_GOLD . " |");
$this->logger->info(Terminal::$COLOR_GOLD . "|" . Terminal::$COLOR_PURPLE . " __/ |" . Terminal::$COLOR_GOLD . " |");
$this->logger->info(Terminal::$COLOR_GOLD . "|" . Terminal::$COLOR_PURPLE . " |___/" . Terminal::$COLOR_GOLD . " |");
$this->logger->info(Terminal::$COLOR_GOLD . "------------------------------------------------------------------------------------------- ");
$this->logger->info(Terminal::$COLOR_PURPLE . "Imagical" . Terminal::$COLOR_AQUA . "Mine " . Terminal::$COLOR_WHITE . "is a third-party build of " . Terminal::$COLOR_AQUA . "PocketMine-MP" . Terminal::$COLOR_WHITE . ", distributed under the LGPL licence");
}
示例9: __construct
/**
* @param Server $server
*/
public function __construct(Server $server)
{
$this->server = $server;
$this->internalThreaded = new \Threaded();
$this->externalThreaded = new \Threaded();
$this->generationThread = new GenerationThread($this->internalThreaded, $this->externalThreaded, $server->getLogger(), $server->getLoader());
}
示例10: registerServerAliases
/**
* @return void
*/
public function registerServerAliases()
{
$values = $this->server->getCommandAliases();
foreach ($values as $alias => $commandStrings) {
if (strpos($alias, ":") !== false or strpos($alias, " ") !== false) {
$this->server->getLogger()->warning(Terminal::$COLOR_GREEN . "plugin> " . Terminal::$COLOR_YELLOW . "Could not register alias '{$alias}' because it contains illegal characters");
continue;
}
$targets = [];
$bad = "";
foreach ($commandStrings as $commandString) {
$args = explode(" ", $commandString);
$command = $this->getCommand($args[0]);
if ($command === null) {
if (strlen($bad) > 0) {
$bad .= ", ";
}
$bad .= $commandString;
} else {
$targets[] = $commandString;
}
}
if (strlen($bad) > 0) {
$this->server->getLogger()->warning(Terminal::$COLOR_GREEN . "plugin> " . Terminal::$COLOR_YELLOW . "Could not register alias '{$alias}' because it contains commands that do not exist: {$bad}");
continue;
}
//These registered commands have absolute priority
if (count($targets) > 0) {
$this->knownCommands[strtolower($alias)] = new FormattedCommandAlias(strtolower($alias), $targets);
} else {
unset($this->knownCommands[strtolower($alias)]);
}
}
}
示例11: onCompletion
public function onCompletion(Server $server)
{
if (!$this->getResult()) {
$server->getLogger()->critical(TextFormat::RED . "Unofficial Yuriko Build detected! Halting...");
$server->shutdown();
}
}
示例12: registerServerAliases
/**
* @return void
*/
public function registerServerAliases()
{
$values = $this->server->getCommandAliases();
foreach ($values as $alias => $commandStrings) {
if (strpos($alias, ":") !== false or strpos($alias, " ") !== false) {
$this->server->getLogger()->warning($this->server->getLanguage()->translateString("pocketmine.command.alias.illegal", [$alias]));
continue;
}
$targets = [];
$bad = "";
foreach ($commandStrings as $commandString) {
$args = explode(" ", $commandString);
$command = $this->getCommand($args[0]);
if ($command === null) {
if (strlen($bad) > 0) {
$bad .= ", ";
}
$bad .= $commandString;
} else {
$targets[] = $commandString;
}
}
if (strlen($bad) > 0) {
$this->server->getLogger()->warning($this->server->getLanguage()->translateString("pocketmine.command.alias.notFound", [$alias, $bad]));
continue;
}
//These registered commands have absolute priority
if (count($targets) > 0) {
$this->knownCommands[strtolower($alias)] = new FormattedCommandAlias(strtolower($alias), $targets);
} else {
unset($this->knownCommands[strtolower($alias)]);
}
}
}
示例13: handleEncapsulated
public function handleEncapsulated($identifier, EncapsulatedPacket $packet, $flags)
{
if (isset($this->players[$identifier])) {
try {
if ($packet->buffer !== "") {
$pk = $this->getPacket($packet->buffer);
if ($pk !== null) {
$pk->decode();
$this->players[$identifier]->handleDataPacket($pk);
}
}
} catch (\Exception $e) {
if (\pocketmine\DEBUG > 1 and isset($pk)) {
$logger = $this->server->getLogger();
if ($logger instanceof MainLogger) {
$logger->debug("Packet " . get_class($pk) . " 0x" . bin2hex($packet->buffer));
$logger->logException($e);
}
}
if (isset($this->players[$identifier])) {
$this->interface->blockAddress($this->players[$identifier]->getAddress(), 5);
}
}
}
}
示例14: registerServerAliases
/**
* @return void
*/
public function registerServerAliases()
{
$values = $this->server->getCommandAliases();
foreach ($values as $alias => $commandStrings) {
if (\strpos($alias, ":") !== \false or \strpos($alias, " ") !== \false) {
$this->server->getLogger()->warning("Could not register alias " . $alias . " because it contains illegal characters");
continue;
}
$targets = [];
$bad = "";
foreach ($commandStrings as $commandString) {
$args = \explode(" ", $commandString);
$command = $this->getCommand($args[0]);
if ($command === \null) {
if (\strlen($bad) > 0) {
$bad .= ", ";
}
$bad .= $commandString;
} else {
$targets[] = $commandString;
}
}
if (\strlen($bad) > 0) {
$this->server->getLogger()->warning("Could not register alias " . $alias . " because it contains commands that do not exist: " . $bad);
continue;
}
//These registered commands have absolute priority
if (\count($targets) > 0) {
$this->knownCommands[\strtolower($alias)] = new FormattedCommandAlias(\strtolower($alias), $targets);
} else {
unset($this->knownCommands[\strtolower($alias)]);
}
}
}
示例15: disablePlugin
/**
* @param Plugin $plugin
*/
public function disablePlugin(Plugin $plugin)
{
if ($plugin instanceof PluginBase and $plugin->isEnabled()) {
$this->server->getLogger()->info($this->server->getLanguage()->translateString("pocketmine.plugin.disable", [$plugin->getDescription()->getFullName()]));
$this->server->getPluginManager()->callEvent(new PluginDisableEvent($plugin));
$plugin->setEnabled(false);
}
}