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


PHP UUID::fromString方法代码示例

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


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

示例1: handleDataPacket

 /**
  * Handles a Minecraft packet
  * TODO: Separate all of this in handlers
  *
  * WARNING: Do not use this, it's only for internal use.
  * Changes to this function won't be recorded on the version.
  *
  * @param DataPacket $packet
  */
 public function handleDataPacket(DataPacket $packet)
 {
     if ($this->connected === false) {
         return;
     }
     if ($packet::NETWORK_ID === ProtocolInfo::BATCH_PACKET) {
         /** @var BatchPacket $packet */
         $this->server->getNetwork()->processBatch($packet, $this);
         return;
     }
     $timings = Timings::getReceiveDataPacketTimings($packet);
     $timings->startTiming();
     $this->server->getPluginManager()->callEvent($ev = new DataPacketReceiveEvent($this, $packet));
     if ($ev->isCancelled()) {
         $timings->stopTiming();
         return;
     }
     switch ($packet::NETWORK_ID) {
         case ProtocolInfo::LOGIN_PACKET:
             if ($this->loggedIn) {
                 break;
             }
             $this->username = TextFormat::clean($packet->username);
             $this->displayName = $this->username;
             $this->iusername = strtolower($this->username);
             $this->setDataProperty(self::DATA_NAMETAG, self::DATA_TYPE_STRING, $this->username, false);
             if (count($this->server->getOnlinePlayers()) >= $this->server->getMaxPlayers() and $this->kick("disconnectionScreen.serverFull", false)) {
                 break;
             }
             if ($packet->protocol !== ProtocolInfo::CURRENT_PROTOCOL) {
                 if ($packet->protocol < ProtocolInfo::CURRENT_PROTOCOL) {
                     $message = "disconnectionScreen.outdatedClient";
                     $pk = new PlayStatusPacket();
                     $pk->status = PlayStatusPacket::LOGIN_FAILED_CLIENT;
                     $this->directDataPacket($pk);
                 } else {
                     $message = "disconnectionScreen.outdatedServer";
                     $pk = new PlayStatusPacket();
                     $pk->status = PlayStatusPacket::LOGIN_FAILED_SERVER;
                     $this->directDataPacket($pk);
                 }
                 $this->close("", $message, false);
                 break;
             }
             $this->randomClientId = $packet->clientId;
             $this->uuid = UUID::fromString($packet->clientUUID);
             $this->rawUUID = $this->uuid->toBinary();
             $valid = true;
             $len = strlen($packet->username);
             if ($len > 16 or $len < 3) {
                 $valid = false;
             }
             for ($i = 0; $i < $len and $valid; ++$i) {
                 $c = ord($packet->username[$i]);
                 if ($c >= ord("a") and $c <= ord("z") or $c >= ord("A") and $c <= ord("Z") or $c >= ord("0") and $c <= ord("9") or $c === ord("_")) {
                     continue;
                 }
                 $valid = false;
                 break;
             }
             if (!$valid or $this->iusername === "rcon" or $this->iusername === "console") {
                 $this->close("", "disconnectionScreen.invalidName");
                 break;
             }
             if (strlen($packet->skin) !== 64 * 32 * 4 and strlen($packet->skin) !== 64 * 64 * 4) {
                 $this->close("", "disconnectionScreen.invalidSkin");
                 break;
             }
             $this->setSkin($packet->skin, $packet->skinId);
             $this->server->getPluginManager()->callEvent($ev = new PlayerPreLoginEvent($this, "Plugin reason"));
             if ($ev->isCancelled()) {
                 $this->close("", $ev->getKickMessage());
                 break;
             }
             $this->onPlayerPreLogin();
             break;
         case ProtocolInfo::MOVE_PLAYER_PACKET:
             if ($this->teleportPosition !== null) {
                 break;
             }
             $newPos = new Vector3($packet->x, $packet->y - $this->getEyeHeight(), $packet->z);
             $revert = false;
             if (!$this->isAlive() or $this->spawned !== true) {
                 $revert = true;
                 $this->forceMovement = new Vector3($this->x, $this->y, $this->z);
             }
             if ($this->forceMovement instanceof Vector3 and (($dist = $newPos->distanceSquared($this->forceMovement)) > 0.1 or $revert)) {
                 $this->sendPosition($this->forceMovement, $packet->yaw, $packet->pitch);
             } else {
                 $packet->yaw %= 360;
                 $packet->pitch %= 360;
//.........这里部分代码省略.........
开发者ID:xxFlare,项目名称:PocketMine-MP,代码行数:101,代码来源:Player.php

示例2: handleDataPacket

 /**
  * Handles a Minecraft packet
  * TODO: Separate all of this in handlers
  *
  * WARNING: Do not use this, it's only for internal use.
  * Changes to this function won't be recorded on the version.
  *
  * @param DataPacket $packet
  */
 public function handleDataPacket(DataPacket $packet)
 {
     if ($this->connected === false) {
         return;
     }
     if ($packet::NETWORK_ID === ProtocolInfo::BATCH_PACKET) {
         /** @var BatchPacket $packet */
         $this->server->getNetwork()->processBatch($packet, $this);
         return;
     }
     $timings = Timings::getReceiveDataPacketTimings($packet);
     $timings->startTiming();
     $this->server->getPluginManager()->callEvent($ev = new DataPacketReceiveEvent($this, $packet));
     if ($ev->isCancelled()) {
         $timings->stopTiming();
         return;
     }
     switch ($packet::NETWORK_ID) {
         case ProtocolInfo::ITEM_FRAME_DROP_ITEM_PACKET:
             $tile = $this->level->getTile($this->temporalVector->setComponents($packet->x, $packet->y, $packet->z));
             if ($tile instanceof ItemFrame) {
                 $block = $this->level->getBlock($tile);
                 $this->server->getPluginManager()->callEvent($ev = new BlockBreakEvent($this, $block, $this->getInventory()->getItemInHand(), true));
                 if (!$ev->isCancelled()) {
                     $item = $tile->getItem();
                     $this->server->getPluginManager()->callEvent($ev = new ItemFrameDropItemEvent($this, $block, $tile, $item));
                     if (!$ev->isCancelled()) {
                         if ($item->getId() !== Item::AIR) {
                             if (mt_rand(0, 10) / 10 < $tile->getItemDropChance()) {
                                 $this->level->dropItem($tile, $item);
                             }
                             $tile->setItem(Item::get(Item::AIR));
                             $tile->setItemRotation(0);
                         }
                     } else {
                         $tile->spawnTo($this);
                     }
                 } else {
                     $tile->spawnTo($this);
                 }
             }
             break;
         case ProtocolInfo::REQUEST_CHUNK_RADIUS_PACKET:
             /*if($this->spawned){
             			$this->viewDistance = $packet->radius ** 2;
             		}*/
             $pk = new ChunkRadiusUpdatedPacket();
             $pk->radius = $this->server->chunkRadius != -1 ? $this->server->chunkRadius : $packet->radius;
             $this->dataPacket($pk);
             break;
         case ProtocolInfo::PLAYER_INPUT_PACKET:
             break;
         case ProtocolInfo::LOGIN_PACKET:
             if ($this->loggedIn) {
                 break;
             }
             $pk = new PlayStatusPacket();
             $pk->status = PlayStatusPacket::LOGIN_SUCCESS;
             $this->dataPacket($pk);
             $this->username = TextFormat::clean($packet->username);
             $this->displayName = $this->username;
             $this->setNameTag($this->username);
             $this->iusername = strtolower($this->username);
             $this->protocol = $packet->protocol;
             if ($this->server->getConfigBoolean("online-mode", false) && $packet->identityPublicKey === null) {
                 $this->kick("disconnectionScreen.notAuthenticated", false);
                 break;
             }
             if (count($this->server->getOnlinePlayers()) >= $this->server->getMaxPlayers() and $this->kick("disconnectionScreen.serverFull", false)) {
                 break;
             }
             if (!in_array($packet->protocol, ProtocolInfo::ACCEPTED_PROTOCOLS)) {
                 if ($packet->protocol < ProtocolInfo::CURRENT_PROTOCOL) {
                     $message = "disconnectionScreen.outdatedClient";
                     $pk = new PlayStatusPacket();
                     $pk->status = PlayStatusPacket::LOGIN_FAILED_CLIENT;
                     $this->directDataPacket($pk);
                 } else {
                     $message = "disconnectionScreen.outdatedServer";
                     $pk = new PlayStatusPacket();
                     $pk->status = PlayStatusPacket::LOGIN_FAILED_SERVER;
                     $this->directDataPacket($pk);
                 }
                 $this->close("", $message, false);
                 break;
             }
             $this->randomClientId = $packet->clientId;
             $this->uuid = UUID::fromString($packet->clientUUID);
             $this->rawUUID = $this->uuid->toBinary();
             $valid = true;
             $len = strlen($packet->username);
//.........这里部分代码省略.........
开发者ID:iTXTech,项目名称:Genisys,代码行数:101,代码来源:Player.php

示例3: handleDataPacket

 /**
  * Handles a Minecraft packet
  * TODO: Separate all of this in handlers
  *
  * WARNING: Do not use this, it's only for internal use.
  * Changes to this function won't be recorded on the version.
  *
  * @param DataPacket $packet
  */
 public function handleDataPacket(DataPacket $packet)
 {
     if ($this->connected === false) {
         return;
     }
     if ($packet::NETWORK_ID === ProtocolInfo::BATCH_PACKET) {
         /** @var BatchPacket $packet */
         $this->server->getNetwork()->processBatch($packet, $this);
         return;
     }
     $timings = Timings::getReceiveDataPacketTimings($packet);
     $timings->startTiming();
     $this->server->getPluginManager()->callEvent($ev = new DataPacketReceiveEvent($this, $packet));
     if ($ev->isCancelled()) {
         $timings->stopTiming();
         return;
     }
     switch ($packet::NETWORK_ID) {
         case ProtocolInfo::ITEM_FRAME_DROP_ITEM_PACKET:
             $tile = $this->level->getTile($this->temporalVector->setComponents($packet->x, $packet->y, $packet->z));
             if ($tile instanceof ItemFrame) {
                 $block = $this->level->getBlock($tile);
                 $this->server->getPluginManager()->callEvent($ev = new BlockBreakEvent($this, $block, $this->getInventory()->getItemInHand(), true));
                 if (!$ev->isCancelled()) {
                     $item = $tile->getItem();
                     $this->server->getPluginManager()->callEvent($ev = new ItemFrameDropItemEvent($this, $block, $tile, $item));
                     if (!$ev->isCancelled()) {
                         if ($item->getId() !== Item::AIR) {
                             if (mt_rand(0, 10) / 10 < $tile->getItemDropChance()) {
                                 $this->level->dropItem($tile, $item);
                             }
                             $tile->setItem(Item::get(Item::AIR));
                             $tile->setItemRotation(0);
                         }
                     } else {
                         $tile->spawnTo($this);
                     }
                 } else {
                     $tile->spawnTo($this);
                 }
             }
             break;
         case ProtocolInfo::REQUEST_CHUNK_RADIUS_PACKET:
             /*if($this->spawned){
             			$this->viewDistance = $packet->radius ** 2;
             		}*/
             $pk = new ChunkRadiusUpdatedPacket();
             $pk->radius = $this->server->chunkRadius != -1 ? $this->server->chunkRadius : $packet->radius;
             $this->dataPacket($pk);
             break;
         case ProtocolInfo::PLAYER_INPUT_PACKET:
             break;
         case ProtocolInfo::LOGIN_PACKET:
             if ($this->loggedIn) {
                 break;
             }
             $pk = new PlayStatusPacket();
             $pk->status = PlayStatusPacket::LOGIN_SUCCESS;
             $this->dataPacket($pk);
             $this->username = TextFormat::clean($packet->username);
             $this->displayName = $this->username;
             $this->setNameTag($this->username);
             $this->iusername = strtolower($this->username);
             $this->protocol = $packet->protocol;
             if (count($this->server->getOnlinePlayers()) >= $this->server->getMaxPlayers() and $this->kick("disconnectionScreen.serverFull", false)) {
                 break;
             }
             if (!in_array($packet->protocol, ProtocolInfo::ACCEPTED_PROTOCOLS)) {
                 if ($packet->protocol < ProtocolInfo::CURRENT_PROTOCOL) {
                     $message = "disconnectionScreen.outdatedClient";
                     $pk = new PlayStatusPacket();
                     $pk->status = PlayStatusPacket::LOGIN_FAILED_CLIENT;
                     $this->directDataPacket($pk);
                 } else {
                     $message = "disconnectionScreen.outdatedServer";
                     $pk = new PlayStatusPacket();
                     $pk->status = PlayStatusPacket::LOGIN_FAILED_SERVER;
                     $this->directDataPacket($pk);
                 }
                 $this->close("", $message, false);
                 break;
             }
             $this->randomClientId = $packet->clientId;
             $this->loginData = ["clientId" => $packet->clientId, "loginData" => null];
             $this->uuid = UUID::fromString($packet->clientUUID);
             $this->rawUUID = $this->uuid->toBinary();
             $valid = true;
             $len = strlen($packet->username);
             if ($len > 16 or $len < 3) {
                 $valid = false;
             }
//.........这里部分代码省略.........
开发者ID:yungtechboy1,项目名称:Genisys,代码行数:101,代码来源:Player.php

示例4: handleDataPacket

 /**
  * Handles a Minecraft packet
  * TODO: Separate all of this in handlers
  *
  * WARNING: Do not use this, it's only for internal use.
  * Changes to this function won't be recorded on the version.
  *
  * @param DataPacket $packet
  */
 public function handleDataPacket(DataPacket $packet)
 {
     if ($this->connected === false) {
         return;
     }
     if ($packet::NETWORK_ID === ProtocolInfo::BATCH_PACKET) {
         /** @var BatchPacket $packet */
         $this->server->getNetwork()->processBatch($packet, $this);
         return;
     }
     $timings = Timings::getReceiveDataPacketTimings($packet);
     $timings->startTiming();
     $this->server->getPluginManager()->callEvent($ev = new DataPacketReceiveEvent($this, $packet));
     if ($ev->isCancelled()) {
         $timings->stopTiming();
         return;
     }
     switch ($packet::NETWORK_ID) {
         case ProtocolInfo::ITEM_FRAME_DROP_ITEM_PACKET:
             $tile = $this->level->getTile($this->temporalVector->setComponents($packet->x, $packet->y, $packet->z));
             if ($tile instanceof ItemFrame) {
                 if ($tile->getItem()->getId() !== Item::AIR) {
                     $this->getServer()->getPluginManager()->callEvent($ev = new ItemFrameDropItemEvent($this->getLevel()->getBlock($tile), $this, $tile->getItem(), $tile->getItemDropChance()));
                     if (!$ev->isCancelled()) {
                         if (mt_rand(0, 10) / 10 <= $tile->getItemDropChance()) {
                             $this->level->dropItem($tile, $tile->getItem());
                         }
                         $tile->setItem(Item::get(Item::AIR));
                         $tile->setItemRotation(0);
                     }
                 }
             }
             break;
         case ProtocolInfo::PLAYER_INPUT_PACKET:
             break;
         case ProtocolInfo::LOGIN_PACKET:
             if ($this->loggedIn) {
                 break;
             }
             $this->username = TextFormat::clean($packet->username);
             $this->displayName = $this->username;
             $this->iusername = strtolower($this->username);
             #$this->setDataProperty(self::DATA_NAMETAG, self::DATA_TYPE_STRING, $this->username, false);
             if ($this->server->getMaxPlayers() !== -1) {
                 if (count($this->server->getOnlinePlayers()) >= $this->server->getMaxPlayers() and $this->kick("disconnectionScreen.serverFull", false)) {
                     break;
                 }
             }
             if (!in_array($packet->protocol, ProtocolInfo::ACCEPT_PROTOCOL)) {
                 if ($packet->protocol < ProtocolInfo::CURRENT_PROTOCOL) {
                     $message = "disconnectionScreen.outdatedClient";
                     $pk = new PlayStatusPacket();
                     $pk->status = PlayStatusPacket::LOGIN_FAILED_CLIENT;
                     $this->directDataPacket($pk);
                 } else {
                     $message = "disconnectionScreen.outdatedServer";
                     $pk = new PlayStatusPacket();
                     $pk->status = PlayStatusPacket::LOGIN_FAILED_SERVER;
                     $this->directDataPacket($pk);
                 }
                 $this->close("", $message, false);
                 break;
             }
             $this->randomClientId = $packet->clientId;
             $this->uuid = UUID::fromString($packet->clientUUID);
             $this->rawUUID = $this->uuid->toBinary();
             $this->identityPublicKey = $packet->identityPublicKey;
             $this->chainData = $packet->chainData;
             $valid = true;
             $len = strlen($packet->username);
             if ($len > 16 or $len < 3) {
                 $valid = false;
             }
             for ($i = 0; $i < $len and $valid; ++$i) {
                 $c = ord($packet->username[$i]);
                 if ($c >= ord("a") and $c <= ord("z") or $c >= ord("A") and $c <= ord("Z") or $c >= ord("0") and $c <= ord("9") or $c === ord("_")) {
                     continue;
                 }
                 $valid = false;
                 break;
             }
             if (!$valid or $this->iusername === "rcon" or $this->iusername === "console") {
                 $this->close("", "disconnectionScreen.invalidName");
                 break;
             }
             if (strlen($packet->skin) !== 64 * 32 * 4 and strlen($packet->skin) !== 64 * 64 * 4) {
                 $this->close("", "disconnectionScreen.invalidSkin");
                 break;
             }
             $this->setSkin($packet->skin, $packet->skinId);
             $this->server->getPluginManager()->callEvent($ev = new PlayerPreLoginEvent($this, "Plugin reason"));
//.........这里部分代码省略.........
开发者ID:robske110,项目名称:ClearSky,代码行数:101,代码来源:Player.php

示例5: bigBrother_authenticate

 public function bigBrother_authenticate($uuid, $onlineModeData = null)
 {
     if ($this->bigBrother_status === 0) {
         $this->bigBrother_uuid = $uuid;
         $this->bigBrother_formatedUUID = UUID::fromString($uuid)->toString();
         $pk = new LoginSuccessPacket();
         $pk->uuid = $this->bigBrother_formatedUUID;
         $pk->name = $this->bigBrother_username;
         $this->putRawPacket($pk);
         $this->bigBrother_status = 1;
         if ($onlineModeData !== null and is_array($onlineModeData)) {
             $this->bigBrother_properties = $onlineModeData;
         }
         foreach ($this->bigBrother_properties as $property) {
             if ($property["name"] === "textures") {
                 $skindata = json_decode(base64_decode($property["value"]), true);
                 if (isset($skindata["textures"]["SKIN"]["url"])) {
                     $skin = $this->getSkinImage($skindata["textures"]["SKIN"]["url"]);
                 }
             }
         }
         $pk = new LoginPacket();
         $pk->username = $this->bigBrother_username;
         $pk->protocol = Info::CURRENT_PROTOCOL;
         $pk->clientUUID = UUID::fromString($uuid);
         $pk->clientId = crc32($this->bigbrother_clientId);
         $pk->serverAddress = "127.0.0.1:25565";
         $pk->clientSecret = "BigBrother";
         if ($skin === null or $skin === false) {
             if ($this->plugin->getConfig()->get("skin-slim")) {
                 $pk->skinName = "Standard_Custom";
             } else {
                 $pk->skinName = "Standard_CustomSlim";
             }
             $pk->skin = file_get_contents($this->plugin->getDataFolder() . $this->plugin->getConfig()->get("skin-yml"));
         } else {
             if (!isset($skindata["textures"]["SKIN"]["metadata"]["model"])) {
                 $pk->skinName = "Standard_Custom";
             } else {
                 $pk->skinName = "Standard_CustomSlim";
             }
             $pk->skin = $skin;
         }
         $this->handleDataPacket($pk);
         /*$pk = new PlayerListPacket();
         			$pk->actionID = PlayerListPacket::TYPE_ADD;
         			$pk->players[] = [
         				$this->bigBrother_uuid,
         				$this->bigBrother_username,
         				$this->bigBrother_properties,
         				$this->getGamemode(),
         				0,
         				false,
         			];
         			$this->putRawPacket($pk);
         
         			$pk = new TitlePacket(); //Set SubTitle for this
         			$pk->actionID = TitlePacket::TYPE_SET_TITLE;
         			$pk->data = TextFormat::toJSON("");
         			$this->putRawPacket($pk);
         
         			$pk = new TitlePacket();
         			$pk->actionID = TitlePacket::TYPE_SET_SUB_TITLE;
         			$pk->data = TextFormat::toJSON(TextFormat::YELLOW . TextFormat::BOLD . "This is a beta version of BigBrother.");
         			$this->putRawPacket($pk);*/
     }
 }
开发者ID:iPocketTeam,项目名称:BigBrother,代码行数:67,代码来源:DesktopPlayer.php


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