當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Player::getPort方法代碼示例

本文整理匯總了PHP中pocketmine\Player::getPort方法的典型用法代碼示例。如果您正苦於以下問題:PHP Player::getPort方法的具體用法?PHP Player::getPort怎麽用?PHP Player::getPort使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pocketmine\Player的用法示例。


在下文中一共展示了Player::getPort方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: forcePlayerDisconnect

 public function forcePlayerDisconnect(Player $player)
 {
     // https://forums.pocketmine.net/threads/temporary-solution-for-transferring-players-in-0-12-1.11759/
     // find out the RakLib interface, which is the network interface that MCPE players connect with
     foreach ($this->getServer()->getNetwork()->getInterfaces() as $interface) {
         if ($interface instanceof RakLibInterface) {
             $raklib = $interface;
             break;
         }
     }
     if (!isset($raklib)) {
         Server::getInstance()->getLogger()->critical(Main::PREFIX . "rakLib not found");
         return;
     }
     // calculate the identifier for the player used by RakLib
     $identifier = $player->getAddress() . ":" . $player->getPort();
     // this method call is the most important one - it sends some signal to RakLib that makes it think that the client has clicked the "Quit to Title" button (or timed out). Some RakLib internal stuff will then tell PocketMine that the player has quitted.
     $raklib->closeSession($identifier, "transfer");
 }
開發者ID:mwvent,項目名稱:WattzMCPE,代碼行數:19,代碼來源:Main.php

示例2: getFixedMessage

 /**
  * @param Player $player
  * @param string $message
  * @return string
  */
 public function getFixedMessage(Player $player, $message = "")
 {
     return str_replace(["{PLAYER_ADDRESS}", "{PLAYER_DISPLAY_NAME}", "{PLAYER_NAME}", "{PLAYER_PORT}"], [$player->getAddress(), $player->getDisplayName(), $player->getName(), $player->getPort()], $message);
 }
開發者ID:pomee4,項目名稱:PocketMine-Plugins,代碼行數:9,代碼來源:PlanB.php

示例3: transferPlayer0

 private function transferPlayer0(Player $player, $ip, $port)
 {
     $sp = new TransferPacket();
     $sp->address = $this->getHostByName($ip);
     $sp->port = $port;
     $player->dataPacket($sp);
     $interfaces = $this->getServer()->getNetwork()->getInterfaces();
     foreach ($interfaces as $interface) {
         if ($interface instanceof RakLibInterface) {
             //				$class = new \ReflectionClass(RakLibInterface::class);
             //				$prop = $class->getProperty("rakLib");
             //				$prop->setAccessible(true);
             //				/** @var RakLibServer $value */
             //				$value = $prop->getValue($interface);
             $identifier = $player->getAddress() . ":" . $player->getPort();
             //				$value->pushMainToThreadPacket(RakLib::PACKET_CLOSE_SESSION . chr(strlen($identifier)) . $identifier);
             $interface->closeSession($identifier, "transferring");
         }
     }
 }
開發者ID:legoboy0215,項目名稱:LegionPE-Theta-Base,代碼行數:20,代碼來源:BasePlugin.php


注:本文中的pocketmine\Player::getPort方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。