本文整理汇总了PHP中pocketmine\Server::getKatana方法的典型用法代码示例。如果您正苦于以下问题:PHP Server::getKatana方法的具体用法?PHP Server::getKatana怎么用?PHP Server::getKatana使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\Server
的用法示例。
在下文中一共展示了Server::getKatana方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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->getKatana()->console->system($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: disablePlugin
/**
* @param Plugin $plugin
*/
public function disablePlugin(Plugin $plugin)
{
if ($plugin instanceof PluginBase and $plugin->isEnabled()) {
$this->server->getKatana()->console->plugin("Disabling " . Terminal::$COLOR_WHITE . $plugin->getDescription()->getFullName());
$this->server->getPluginManager()->callEvent(new PluginDisableEvent($plugin));
$plugin->setEnabled(false);
}
}
示例3: define
//Found Git information!
define("pocketmine\\GIT_COMMIT", strtolower(trim(file_get_contents(\pocketmine\PATH . ".git/refs/heads/master"))));
} else {
//Unknown :(
define("pocketmine\\GIT_COMMIT", str_repeat("00", 20));
}
@define("ENDIANNESS", pack("d", 1) === "?ð" ? Binary::BIG_ENDIAN : Binary::LITTLE_ENDIAN);
@define("INT32_MASK", is_int(4294967295.0) ? 4294967295.0 : -1);
@ini_set("opcache.mmap_base", bin2hex(Utils::getRandomBytes(8, false)));
//Fix OPCache address errors
if (!file_exists(\pocketmine\DATA . "server.properties") and !isset($opts["no-wizard"])) {
new Installer();
}
if (\Phar::running(true) === "") {
$logger->warning("Non-packaged Katana installation detected, do not use on production.");
}
ThreadManager::init();
$server = new Server($autoloader, $logger, \pocketmine\PATH, \pocketmine\DATA, \pocketmine\PLUGIN_PATH);
$server->getKatana()->console->system("Stopping other threads");
foreach (ThreadManager::getInstance()->getAll() as $id => $thread) {
$server->getKatana()->console->system("Stopping " . Terminal::$COLOR_WHITE . (new \ReflectionClass($thread))->getShortName() . Terminal::$COLOR_GRAY . " thread");
$thread->quit();
}
$killer = new ServerKiller(8);
$killer->start();
$killer->detach();
$logger->shutdown();
$logger->join();
echo Terminal::$FORMAT_RESET . "\n";
exit(0);
}
示例4: chunkRequestCallback
public function chunkRequestCallback($x, $z, $payload, $ordering = FullChunkDataPacket::ORDER_COLUMNS)
{
$this->timings->syncChunkSendTimer->startTiming();
$index = Level::chunkHash($x, $z);
$this->saveChunkToDisk($x, $z, $payload, $ordering);
if (isset($this->chunkSendTasks[$index])) {
foreach ($this->chunkSendQueue[$index] as $player) {
/** @var Player $player */
if ($player->isConnected() and isset($player->usedChunks[$index])) {
$player->sendBatchedChunk($x, $z, $this->chunkCache[$x . ":" . $z]);
}
}
unset($this->chunkSendQueue[$index]);
unset($this->chunkSendTasks[$index]);
}
$this->timings->syncChunkSendTimer->stopTiming();
if (!$this->server->getKatana()->getProperty("cache.save-to-ram", true)) {
unset($this->chunkCache[$x . ":" . $z]);
}
}
示例5: saveChunkToDisk
public function saveChunkToDisk($x, $z, $payload, $ordering = FullChunkDataPacket::ORDER_COLUMNS)
{
// When the payload of the chunk has been calculated it, save it if possible to save future CPU cycles
/** @var Player $player */
if (file_exists("chunk_cache/" . $this->getName() . "/" . $x . "_" . $z . ".dat")) {
return $this->loadChunkFromDisk($x, $z);
}
$pk = new FullChunkDataPacket();
$pk->chunkX = $x;
$pk->chunkZ = $z;
$pk->order = $ordering;
$pk->data = $payload;
$pk->encode();
// all chunks are zlib_encoded, level is arbitrary but 6 is a good match between device CPU power needed
// and bandwidth
$data = zlib_encode(Binary::writeInt(strlen($pk->buffer)) . $pk->buffer, ZLIB_ENCODING_DEFLATE, 6);
if (!$this->server->getKatana()->getProperty("caching.save-to-disk", true)) {
return $data;
}
file_put_contents("chunk_cache/" . $this->getName() . "/" . $x . "_" . $z . ".dat", $data);
return $data;
}