当前位置: 首页>>代码示例>>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;未经允许,请勿转载。