本文整理汇总了PHP中pocketmine\Server::getLevels方法的典型用法代码示例。如果您正苦于以下问题:PHP Server::getLevels方法的具体用法?PHP Server::getLevels怎么用?PHP Server::getLevels使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\Server
的用法示例。
在下文中一共展示了Server::getLevels方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generalData
private function generalData()
{
$version = new VersionString();
$this->data["general"] = [];
$this->data["general"]["version"] = $version->get(false);
$this->data["general"]["build"] = $version->getBuild();
$this->data["general"]["protocol"] = Info::CURRENT_PROTOCOL;
$this->data["general"]["api"] = \pocketmine\API_VERSION;
$this->data["general"]["git"] = \pocketmine\GIT_COMMIT;
$this->data["general"]["raklib"] = RakLib::VERSION;
$this->data["general"]["uname"] = php_uname("a");
$this->data["general"]["php"] = phpversion();
$this->data["general"]["zend"] = zend_version();
$this->data["general"]["php_os"] = PHP_OS;
$this->data["general"]["os"] = Utils::getOS();
$this->addLine("Genisys version: " . $version->get(false) . " #" . $version->getBuild() . " [Protocol " . Info::CURRENT_PROTOCOL . "; API " . API_VERSION . "]");
$this->addLine("uname -a: " . php_uname("a"));
$this->addLine("PHP version: " . phpversion());
$this->addLine("Zend version: " . zend_version());
$this->addLine("OS : " . PHP_OS . ", " . Utils::getOS());
$this->addLine();
$this->addLine("Server uptime: " . $this->server->getUptime());
$this->addLine("Number of loaded worlds: " . count($this->server->getLevels()));
$this->addLine("Players online: " . count($this->server->getOnlinePlayers()) . "/" . $this->server->getMaxPlayers());
}
示例2: select
public static function select(Server $srv, CommandSender $sender, array $args)
{
$result = [];
if (!isset($args["type"])) {
$args["type"] = "player";
}
foreach ($srv->getLevels() as $l) {
foreach ($l->getEntities() as $e) {
if (count($args) && !$owner->checkSelectors($args, $sender, $e)) {
continue;
}
if ($e instanceof Player) {
$result[] = $e->getName();
} else {
$result[] = "e" . $e->getId();
}
}
}
if (!isset($args["c"])) {
$args["c"] = 1;
}
$c = [];
$n = intval($args["c"]);
while ($n-- > 0 && count($result)) {
$i = array_rand($result);
$c[] = $result[$i];
unset($result[$i]);
}
return $c;
}
示例3: triggerGarbageCollector
public function triggerGarbageCollector()
{
Timings::$garbageCollectorTimer->startTiming();
if ($this->garbageCollectionAsync) {
$size = $this->server->getScheduler()->getAsyncTaskPoolSize();
for ($i = 0; $i < $size; ++$i) {
$this->server->getScheduler()->scheduleAsyncTaskToWorker(new GarbageCollectionTask(), $i);
}
}
$cycles = gc_collect_cycles();
foreach ($this->server->getLevels() as $level) {
$level->doChunkGarbageCollection();
}
Timings::$garbageCollectorTimer->stopTiming();
return $cycles;
}
示例4: select
public static function select(Server $srv, CommandSender $sender, array $args)
{
$result = [];
foreach ($srv->getLevels() as $l) {
foreach ($l->getEntities() as $e) {
if (count($args) && !$owner->checkSelectors($args, $sender, $e)) {
continue;
}
if ($e instanceof Player) {
$result[] = $e->getName();
} else {
$result[] = "e" . $e->getId();
}
}
}
return $result;
}
示例5: trigger
public function trigger($memory, $limit, $global = false, $triggerCount = 0)
{
$this->server->getLogger()->debug("[Memory Manager] " . ($global ? "Global " : "") . "Low memory triggered, limit " . round($limit / 1024 / 1024, 2) . "MB, using " . round($memory / 1024 / 1024, 2) . "MB");
if ($this->cacheTrigger) {
foreach ($this->server->getLevels() as $level) {
$level->clearCache(true);
}
}
if ($this->chunkTrigger and $this->chunkCollect) {
foreach ($this->server->getLevels() as $level) {
$level->doChunkGarbageCollection();
}
}
$ev = new LowMemoryEvent($memory, $limit, $global, $triggerCount);
$this->server->getPluginManager()->callEvent($ev);
$cycles = 0;
if ($this->garbageCollectionTrigger) {
$cycles = $this->triggerGarbageCollector();
}
$this->server->getLogger()->debug("[Memory Manager] Freed " . round($ev->getMemoryFreed() / 1024 / 1024, 2) . "MB, {$cycles} cycles");
}