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


PHP Server::getScheduler方法代码示例

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


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

示例1: __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->getLogger()->info("Starting remote control listener");
     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->getLogger()->info("RCON running on {$addr}:{$port}");
     $this->server->getScheduler()->scheduleRepeatingTask(new CallbackTask([$this, "check"]), 3);
 }
开发者ID:rryy,项目名称:PocketMine-MP,代码行数:26,代码来源:RCON.php

示例2: __construct

 public function __construct(PlayHarder $plugin)
 {
     if (self::$instance == null) {
         self::$instance = $this;
     }
     $this->server = Server::getInstance();
     $this->plugin = $plugin;
     $this->server->getScheduler()->scheduleRepeatingTask(new AutoUnloadTask($this), 12000);
 }
开发者ID:Gumbrat,项目名称:PlayHarder,代码行数:9,代码来源:AttributeLoader.php

示例3: doUpgrade

 public function doUpgrade()
 {
     if (!$this->isupdating) {
         $this->isupdating = true;
         $this->server->getScheduler()->scheduleAsyncTask(new Upgrader($this->updateInfo['download_url'], $this->updateInfo['fingerprint'], "phar://" . $this->server->getDataPath() . "ClearSkyNewVersion" . "phar"));
         //Is an .phar needed?
     } else {
         Command::broadcastCommandMessage($sender, new TranslationContainer("commands.upgrade.isUpdating"));
     }
 }
开发者ID:ClearSkyTeam,项目名称:ClearSky,代码行数:10,代码来源:AutoUpdater.php

示例4: disablePlugin

 /**
  * @param Plugin $plugin
  */
 public function disablePlugin(Plugin $plugin)
 {
     if ($plugin->isEnabled()) {
         $plugin->getPluginLoader()->disablePlugin($plugin);
         $this->server->getScheduler()->cancelTasks($plugin);
         HandlerList::unregisterAll($plugin);
         foreach ($plugin->getDescription()->getPermissions() as $perm) {
             $this->removePermission($perm);
         }
     }
 }
开发者ID:boybook,项目名称:PocketMine-MP,代码行数:14,代码来源:PluginManager.php

示例5: 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();
     Timings::$garbageCollectorTimer->stopTiming();
     return $cycles;
 }
开发者ID:ianju,项目名称:PocketMine-MP,代码行数:13,代码来源:MemoryManager.php

示例6: onCompletion

 /**
  * @param Server $server
  */
 public function onCompletion(Server $server)
 {
     /** @var Loader $esspe */
     $esspe = $server->getPluginManager()->getPlugin("EssentialsPE");
     if ($esspe->getDescription()->getVersion() < ($v = $this->getResult()["version"])) {
         $continue = true;
         $message = TextFormat::AQUA . "[EssentialsPE]" . TextFormat::GREEN . " A new " . TextFormat::YELLOW . $this->build . TextFormat::GREEN . " version of EssentialsPE found! Version: " . TextFormat::YELLOW . $v . TextFormat::GREEN . ($this->install !== true ? "" : ", " . TextFormat::LIGHT_PURPLE . "Installing...");
     } else {
         $continue = false;
         $message = TextFormat::AQUA . "[EssentialsPE]" . TextFormat::YELLOW . " No new version found, you're using the latest version of EssentialsPE";
     }
     $esspe->broadcastUpdateAvailability($message);
     if ($continue && $this->install) {
         $server->getScheduler()->scheduleAsyncTask($task = new UpdateInstallTask($esspe, $this->getResult()["downloadURL"], $server->getPluginPath(), $v));
         $esspe->updaterDownloadTask = $task;
     }
 }
开发者ID:mwvent,项目名称:WattzEssentialsPE,代码行数:20,代码来源:UpdateFetchTask.php

示例7: disablePlugin

 /**
  * @param Plugin $plugin
  */
 public function disablePlugin(Plugin $plugin)
 {
     if ($plugin->isEnabled()) {
         try {
             $plugin->getPluginLoader()->disablePlugin($plugin);
         } catch (\Exception $e) {
             $logger = Server::getInstance()->getLogger();
             if ($logger instanceof MainLogger) {
                 $logger->logException($e);
             }
         }
         $this->server->getScheduler()->cancelTasks($plugin);
         HandlerList::unregisterAll($plugin);
         foreach ($plugin->getDescription()->getPermissions() as $perm) {
             $this->removePermission($perm);
         }
     }
 }
开发者ID:TylerGames,项目名称:PocketMine-MP,代码行数:21,代码来源:PluginManager.php

示例8: collectTasks

 public function collectTasks()
 {
     Timings::$schedulerAsyncTimer->startTiming();
     foreach ($this->tasks as $task) {
         if (!$task->isGarbage()) {
             $task->checkProgressUpdates($this->server);
         }
         if ($task->isGarbage() and !$task->isRunning() and !$task->isCrashed()) {
             if (!$task->hasCancelledRun()) {
                 $task->onCompletion($this->server);
                 $this->server->getScheduler()->removeLocalComplex($task);
             }
             $this->removeTask($task);
         } elseif ($task->isTerminated() or $task->isCrashed()) {
             $this->server->getLogger()->critical("Could not execute asynchronous task " . (new \ReflectionClass($task))->getShortName() . ": Task crashed");
             $this->removeTask($task, true);
         }
     }
     Timings::$schedulerAsyncTimer->stopTiming();
 }
开发者ID:xxFlare,项目名称:PocketMine-MP,代码行数:20,代码来源:AsyncPool.php

示例9: processChunkRequest

 protected function processChunkRequest()
 {
     if (count($this->chunkSendQueue) > 0) {
         $this->timings->syncChunkSendTimer->startTiming();
         $x = null;
         $z = null;
         foreach ($this->chunkSendQueue as $index => $players) {
             if (isset($this->chunkSendTasks[$index])) {
                 continue;
             }
             if (PHP_INT_SIZE === 8) {
                 $x = $index >> 32 << 32 >> 32;
                 $z = ($index & 4294967295.0) << 32 >> 32;
             } else {
                 list($x, $z) = explode(":", $index);
                 $x = (int) $x;
                 $z = (int) $z;
             }
             if (ADVANCED_CACHE == true and ($cache = Cache::get("world:" . $this->getId() . ":" . $index)) !== false) {
                 /** @var Player[] $players */
                 foreach ($players as $player) {
                     if ($player->isConnected() and isset($player->usedChunks[$index])) {
                         $player->sendChunk($x, $z, $cache);
                     }
                 }
                 unset($this->chunkSendQueue[$index]);
             } else {
                 $this->chunkSendTasks[$index] = true;
                 $this->timings->syncChunkSendPrepareTimer->startTiming();
                 $task = $this->provider->requestChunkTask($x, $z);
                 if ($task instanceof AsyncTask) {
                     $this->server->getScheduler()->scheduleAsyncTask($task);
                 }
                 $this->timings->syncChunkSendPrepareTimer->stopTiming();
             }
         }
         $this->timings->syncChunkSendTimer->stopTiming();
     }
 }
开发者ID:RedstoneAlmeida,项目名称:Steadfast2,代码行数:39,代码来源:Level.php

示例10: generateChunk

 public function generateChunk($x, $z, $force = false)
 {
     if (count($this->chunkGenerationQueue) >= $this->chunkGenerationQueueSize and !$force) {
         return;
     }
     if (!isset($this->chunkGenerationQueue[$index = Level::chunkHash($x, $z)])) {
         Timings::$generationTimer->startTiming();
         $this->chunkGenerationQueue[$index] = true;
         $task = new GenerationTask($this, $this->getChunk($x, $z, true));
         $this->server->getScheduler()->scheduleAsyncTask($task);
         Timings::$generationTimer->stopTiming();
     }
 }
开发者ID:robozeri,项目名称:Yuriko-MP,代码行数:13,代码来源:Level.php

示例11: processChunkRequest

 protected function processChunkRequest()
 {
     if (count($this->chunkSendQueue) > 0) {
         $x = null;
         $z = null;
         foreach ($this->chunkSendQueue as $index => $players) {
             if (isset($this->chunkSendTasks[$index])) {
                 continue;
             }
             Level::getXZ($index, $x, $z);
             if (ADVANCED_CACHE == true and ($cache = Cache::get("world:" . $this->getID() . ":" . $index)) !== false) {
                 /** @var Player[] $players */
                 foreach ($players as $player) {
                     if (isset($player->usedChunks[$index])) {
                         $player->sendChunk($x, $z, $cache);
                     }
                 }
                 unset($this->chunkSendQueue[$index]);
             } else {
                 $this->chunkSendTasks[$index] = true;
                 $task = $this->provider->requestChunkTask($x, $z);
                 if ($task instanceof AsyncTask) {
                     $this->server->getScheduler()->scheduleAsyncTask($task);
                 }
             }
         }
     }
 }
开发者ID:boybook,项目名称:PocketMine-MP,代码行数:28,代码来源:Level.php

示例12: generateChunk

 public function generateChunk($x, $z, $force = \false)
 {
     if (\count($this->chunkGenerationQueue) >= $this->chunkGenerationQueueSize and !$force) {
         return;
     }
     if (!isset($this->chunkGenerationQueue[$index = \PHP_INT_SIZE === 8 ? ($x & 0xffffffff) << 32 | $z & 0xffffffff : $x . ":" . $z])) {
         Timings::$generationTimer->startTiming();
         $this->chunkGenerationQueue[$index] = \true;
         $task = new GenerationTask($this, $this->getChunk($x, $z, \true));
         $this->server->getScheduler()->scheduleAsyncTask($task);
         Timings::$generationTimer->stopTiming();
     }
 }
开发者ID:xpyctum,项目名称:PocketMinePlusPlus,代码行数:13,代码来源:Level.php

示例13: processChunkRequest

 private function processChunkRequest()
 {
     if (count($this->chunkSendQueue) > 0) {
         $this->timings->syncChunkSendTimer->startTiming();
         $x = null;
         $z = null;
         foreach ($this->chunkSendQueue as $index => $players) {
             if (isset($this->chunkSendTasks[$index])) {
                 continue;
             }
             Level::getXZ($index, $x, $z);
             $this->chunkSendTasks[$index] = true;
             // Gets chunks from disk or cache if it can
             if (isset($this->chunkCache[$x . ":" . $z]) or $this->loadChunkFromDisk($x, $z)) {
                 foreach ($players as $player) {
                     // Found chunk? Call special function to send just the payload
                     $player->sendBatchedChunk($x, $z, $this->chunkCache[$x . ":" . $z]);
                 }
                 unset($this->chunkSendQueue[$index]);
                 unset($this->chunkSendTasks[$index]);
                 $this->server->chunkUsedTimes[$this->getName()][$x . ":" . $z] = time();
                 continue;
             }
             $this->timings->syncChunkSendPrepareTimer->startTiming();
             $task = $this->provider->requestChunkTask($x, $z);
             if ($task !== null) {
                 $this->server->getScheduler()->scheduleAsyncTask($task);
             }
             $this->timings->syncChunkSendPrepareTimer->stopTiming();
         }
         $this->timings->syncChunkSendTimer->stopTiming();
     }
 }
开发者ID:AbelGamerC,项目名称:Katana,代码行数:33,代码来源:Level.php

示例14: addLightning

 public function addLightning(Vector3 $pos, $autoRemoveTime = 3)
 {
     $nbt = new Compound("", ["Pos" => new Enum("Pos", [new Double("", $pos->getX()), new Double("", $pos->getY()), new Double("", $pos->getZ())]), "Motion" => new Enum("Motion", [new Double("", 0), new Double("", 0), new Double("", 0)]), "Rotation" => new Enum("Rotation", [new Float("", 0), new Float("", 0)])]);
     $chunk = $this->getChunk($pos->x >> 4, $pos->z >> 4, false);
     $lightning = new Lightning($chunk, $nbt);
     $lightning->spawnToAll();
     $this->server->getScheduler()->scheduleDelayedTask(new CallbackTask([$lightning, "close"]), $autoRemoveTime * 20);
 }
开发者ID:linuzo,项目名称:ImagicalMine,代码行数:8,代码来源:Level.php

示例15: generateChunk

 public function generateChunk($x, $z, $force = \false)
 {
     if (\count($this->chunkGenerationQueue) >= $this->chunkGenerationQueueSize and !$force) {
         return;
     }
     if (!isset($this->chunkGenerationQueue[$index = ($x & 4294967295.0) << 32 | $z & 4294967295.0])) {
         Timings::$generationTimer->startTiming();
         $this->chunkGenerationQueue[$index] = \true;
         $task = new GenerationTask($this, $this->getChunk($x, $z, \true));
         $this->server->getScheduler()->scheduleAsyncTask($task);
         Timings::$generationTimer->stopTiming();
     }
 }
开发者ID:ken77731,项目名称:PocketMine-0.13.0,代码行数:13,代码来源:Level__64bit.php


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