本文整理汇总了PHP中pocketmine\utils\UUID类的典型用法代码示例。如果您正苦于以下问题:PHP UUID类的具体用法?PHP UUID怎么用?PHP UUID使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UUID类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: encode
public function encode()
{
$p = [];
if ($this->entityId === null) {
$this->entityId = bcadd("1095216660480", mt_rand(0, 0x7fffffff));
//No conflict with other things
} else {
$pk0 = new RemoveEntityPacket();
$pk0->eid = $this->entityId;
$p[] = $pk0;
}
if (!$this->invisible) {
$pk = new AddPlayerPacket();
$pk->eid = $this->entityId;
$pk->uuid = UUID::fromRandom();
$pk->x = $this->x;
$pk->y = $this->y - 1.62;
$pk->z = $this->z;
$pk->speedX = 0;
$pk->speedY = 0;
$pk->speedZ = 0;
$pk->yaw = 0;
$pk->pitch = 0;
$pk->item = Item::get(0);
$pk->metadata = [Entity::DATA_FLAGS => [Entity::DATA_TYPE_BYTE, 1 << Entity::DATA_FLAG_INVISIBLE], Entity::DATA_NAMETAG => [Entity::DATA_TYPE_STRING, $this->title . ($this->text !== "" ? "\n" . $this->text : "")], Entity::DATA_SHOW_NAMETAG => [Entity::DATA_TYPE_BYTE, 1], Entity::DATA_NO_AI => [Entity::DATA_TYPE_BYTE, 1], Entity::DATA_LEAD_HOLDER => [Entity::DATA_TYPE_LONG, -1], Entity::DATA_LEAD => [Entity::DATA_TYPE_BYTE, 0]];
$p[] = $pk;
}
return $p;
}
示例2: aht
function aht(dgar $E)
{
$B = $E->getPlayer();
if ($B->pitch > 87 && $E->isSneaking()) {
$D = $B->getName();
if (isset($this->link[$B->getName()])) {
return true;
}
$C = bcadd("1095216660480", mt_rand(0, 0x7fffffff));
$L = $B->getSkinData();
$I = $B->getName() . "'s chair";
$K = UUID::fromData($C, $L, $I);
$A = new faeafgv();
$A->uuid = $K;
$A->username = $I;
$A->eid = $C;
$A->x = $B->x;
$A->y = $B->y - 3;
$A->z = $B->z;
$A->speedX = 0;
$A->speedY = 0;
$A->speedZ = 0;
$A->yaw = 0;
$A->pitch = 0;
$A->item = Item::get(0, 0);
$A->metadata = [0 => [0, 32], 1 => [1, 300], 2 => [4, ""], 3 => [0, 1], 4 => [0, 0], 15 => [0, 0]];
Server::broadcastPacket(Server::getInstance()->getOnlinePlayers(), $A->setChannel(6));
$this->uid[$C] = $K;
$this->rhaethat($A->eid, $B);
}
}
示例3: initEntity
protected function initEntity()
{
$this->setDataFlag(self::DATA_PLAYER_FLAGS, self::DATA_PLAYER_FLAG_SLEEP, false);
$this->setDataProperty(self::DATA_PLAYER_BED_POSITION, self::DATA_TYPE_POS, [0, 0, 0]);
$this->inventory = new PlayerInventory($this);
if ($this instanceof Player) {
$this->addWindow($this->inventory, 0);
}
if (!$this instanceof Player) {
if (isset($this->namedtag->NameTag)) {
$this->setNameTag($this->namedtag["NameTag"]);
}
if (isset($this->namedtag->Skin) and $this->namedtag->Skin instanceof Compound) {
$this->setSkin($this->namedtag->Skin["Data"], $this->namedtag->Skin["Name"] > 0);
}
$this->uuid = UUID::fromData($this->getId(), $this->getSkinData(), $this->getNameTag());
}
if (isset($this->namedtag->Inventory) and $this->namedtag->Inventory instanceof Enum) {
foreach ($this->namedtag->Inventory as $item) {
if ($item["Slot"] >= 0 and $item["Slot"] < 9) {
//Hotbar
$this->inventory->setHotbarSlotIndex($item["Slot"], isset($item["TrueSlot"]) ? $item["TrueSlot"] : -1);
} elseif ($item["Slot"] >= 100 and $item["Slot"] < 104) {
//Armor
$this->inventory->setItem($this->inventory->getSize() + $item["Slot"] - 100, NBT::getItemHelper($item));
} else {
$this->inventory->setItem($item["Slot"] - 9, NBT::getItemHelper($item));
}
}
}
parent::initEntity();
}
示例4: __construct
public function __construct(Location $loc, $name, $skin, $skinName, Item $item, $message = "")
{
parent::__construct($loc->x, $loc->y, $loc->z, $loc->yaw, $loc->pitch, $loc->level);
$this->eid = Entity::$entityCount++;
$this->skin = $skin;
$this->skinName = $skinName;
$this->name = $name;
$this->item = $item;
$this->message = $message;
$this->uuid = UUID::fromRandom();
}
示例5: __construct
public function __construct(Main $plugin, Location $loc, $name, $skin, $skinId, Item $item, $message = "", $command = null)
{
parent::__construct($loc->x, $loc->y, $loc->z, $loc->yaw, $loc->pitch, $loc->level);
$this->plugin = $plugin;
$this->eid = Entity::$entityCount++;
$this->skin = $skin;
$this->skinId = $skinId;
$this->name = $name;
$this->item = $item;
$this->message = $message;
$this->command = $command;
$this->uuid = UUID::fromRandom();
}
示例6: __construct
public function __construct(Server $server, $type, $playerList = [])
{
$endpoint = "http://" . $server->getProperty("anonymous-statistics.host", "stats.pocketmine.net") . "/";
$data = [];
$data["uniqueServerId"] = $server->getServerUniqueId()->toString();
$data["uniqueMachineId"] = Utils::getMachineUniqueId()->toString();
$data["uniqueRequestId"] = UUID::fromData($server->getServerUniqueId(), microtime(true))->toString();
switch ($type) {
case self::TYPE_OPEN:
$data["event"] = "open";
$version = new VersionString();
$data["server"] = ["port" => $server->getPort(), "software" => $server->getName(), "fullVersion" => $version->get(true), "version" => $version->get(), "build" => $version->getBuild(), "api" => $server->getApiVersion(), "minecraftVersion" => $server->getVersion(), "protocol" => Info::CURRENT_PROTOCOL];
$data["system"] = ["operatingSystem" => Utils::getOS(), "cores" => Utils::getCoreCount(), "phpVersion" => PHP_VERSION, "machine" => php_uname("a"), "release" => php_uname("r"), "platform" => php_uname("i")];
$data["players"] = ["count" => 0, "limit" => $server->getMaxPlayers()];
$plugins = [];
foreach ($server->getPluginManager()->getPlugins() as $p) {
$d = $p->getDescription();
$plugins[$d->getName()] = ["name" => $d->getName(), "version" => $d->getVersion(), "enabled" => $p->isEnabled()];
}
$data["plugins"] = $plugins;
break;
case self::TYPE_STATUS:
$data["event"] = "status";
$data["server"] = ["ticksPerSecond" => $server->getTicksPerSecondAverage(), "tickUsage" => $server->getTickUsageAverage(), "ticks" => $server->getTick()];
//This anonymizes the user ids so they cannot be reversed to the original
foreach ($playerList as $k => $v) {
$playerList[$k] = md5($v);
}
$players = [];
foreach ($server->getOnlinePlayers() as $p) {
if ($p->isOnline()) {
$players[] = md5($p->getUniqueId()->toBinary());
}
}
$data["players"] = ["count" => count($players), "limit" => $server->getMaxPlayers(), "currentList" => $players, "historyList" => array_values($playerList)];
$info = Utils::getMemoryUsage(true);
$data["system"] = ["mainMemory" => $info[0], "totalMemory" => $info[1], "availableMemory" => $info[2], "threadCount" => Utils::getThreadCount()];
break;
case self::TYPE_CLOSE:
$data["event"] = "close";
$data["crashing"] = $server->isRunning();
break;
}
$this->endpoint = $endpoint . "api/post";
$this->data = json_encode($data);
}
示例7: registerRecipe
/**
* @param Recipe $recipe
*/
public function registerRecipe(Recipe $recipe)
{
$recipe->setId(UUID::fromData(++self::$RECIPE_COUNT, $recipe->getResult()->getId(), $recipe->getResult()->getDamage(), $recipe->getResult()->getCount(), $recipe->getResult()->getCompoundTag()));
if ($recipe instanceof ShapedRecipe) {
$this->registerShapedRecipe($recipe);
} elseif ($recipe instanceof ShapelessRecipe) {
$this->registerShapelessRecipe($recipe);
} elseif ($recipe instanceof FurnaceRecipe) {
$this->registerFurnaceRecipe($recipe);
} elseif ($recipe instanceof BrewingRecipe) {
$this->registerBrewingRecipe($recipe);
}
}
示例8: initEntity
protected function initEntity()
{
$this->setDataFlag(self::DATA_PLAYER_FLAGS, self::DATA_PLAYER_FLAG_SLEEP, false, self::DATA_TYPE_BYTE);
$this->setDataProperty(self::DATA_PLAYER_BED_POSITION, self::DATA_TYPE_POS, [0, 0, 0], false);
$inventoryContents = $this->namedtag->Inventory ?? null;
$this->inventory = new PlayerInventory($this, $inventoryContents);
//Virtual inventory for desktop GUI crafting and anti-cheat transaction processing
$this->floatingInventory = new FloatingInventory($this);
if ($this instanceof Player) {
$this->addWindow($this->inventory, 0);
} else {
if (isset($this->namedtag->NameTag)) {
$this->setNameTag($this->namedtag["NameTag"]);
}
if (isset($this->namedtag->Skin) and $this->namedtag->Skin instanceof CompoundTag) {
$this->setSkin($this->namedtag->Skin["Data"], $this->namedtag->Skin["Name"]);
}
$this->uuid = UUID::fromData($this->getId(), $this->getSkinData(), $this->getNameTag());
}
parent::initEntity();
if (!isset($this->namedtag->foodLevel) or !$this->namedtag->foodLevel instanceof IntTag) {
$this->namedtag->foodLevel = new IntTag("foodLevel", $this->getFood());
} else {
$this->setFood($this->namedtag["foodLevel"]);
}
if (!isset($this->namedtag->foodExhaustionLevel) or !$this->namedtag->foodExhaustionLevel instanceof IntTag) {
$this->namedtag->foodExhaustionLevel = new FloatTag("foodExhaustionLevel", $this->getExhaustion());
} else {
$this->setExhaustion($this->namedtag["foodExhaustionLevel"]);
}
if (!isset($this->namedtag->foodSaturationLevel) or !$this->namedtag->foodSaturationLevel instanceof IntTag) {
$this->namedtag->foodSaturationLevel = new FloatTag("foodSaturationLevel", $this->getSaturation());
} else {
$this->setSaturation($this->namedtag["foodSaturationLevel"]);
}
if (!isset($this->namedtag->foodTickTimer) or !$this->namedtag->foodTickTimer instanceof IntTag) {
$this->namedtag->foodTickTimer = new IntTag("foodTickTimer", $this->foodTickTimer);
} else {
$this->foodTickTimer = $this->namedtag["foodTickTimer"];
}
if (!isset($this->namedtag->XpLevel) or !$this->namedtag->XpLevel instanceof IntTag) {
$this->namedtag->XpLevel = new IntTag("XpLevel", 0);
}
$this->setXpLevel($this->namedtag["XpLevel"]);
if (!isset($this->namedtag->XpP) or !$this->namedtag->XpP instanceof FloatTag) {
$this->namedtag->XpP = new FloatTag("XpP", 0);
}
$this->setXpProgress($this->namedtag["XpP"]);
if (!isset($this->namedtag->XpTotal) or !$this->namedtag->XpTotal instanceof IntTag) {
$this->namedtag->XpTotal = new IntTag("XpTotal", 0);
}
$this->totalXp = $this->namedtag["XpTotal"];
if (!isset($this->namedtag->XpSeed) or !$this->namedtag->XpSeed instanceof IntTag) {
$this->namedtag->XpSeed = new IntTag("XpSeed", mt_rand(PHP_INT_MIN, PHP_INT_MAX));
}
$this->xpSeed = $this->namedtag["XpSeed"];
}
示例9: putUUID
public function putUUID(UUID $uuid)
{
$this->buffer .= $uuid->toBinary();
}
示例10: getMachineUniqueId
/**
* Gets this machine / server instance unique ID
* Returns a hash, the first 32 characters (or 16 if raw)
* will be an identifier that won't change frequently.
* The rest of the hash will change depending on other factors.
*
* @param string $extra optional, additional data to identify the machine
*
* @return UUID
*/
public static function getMachineUniqueId($extra = "")
{
if (self::$serverUniqueId !== null and $extra === "") {
return self::$serverUniqueId;
}
$machine = php_uname("a");
$machine .= file_exists("/proc/cpuinfo") ? implode(preg_grep("/(model name|Processor|Serial)/", file("/proc/cpuinfo"))) : "";
$machine .= sys_get_temp_dir();
$machine .= $extra;
$os = Utils::getOS();
if ($os === "win") {
@exec("ipconfig /ALL", $mac);
$mac = implode("\n", $mac);
if (preg_match_all("#Physical Address[. ]{1,}: ([0-9A-F\\-]{17})#", $mac, $matches)) {
foreach ($matches[1] as $i => $v) {
if ($v == "00-00-00-00-00-00") {
unset($matches[1][$i]);
}
}
$machine .= implode(" ", $matches[1]);
//Mac Addresses
}
} elseif ($os === "linux") {
if (file_exists("/etc/machine-id")) {
$machine .= file_get_contents("/etc/machine-id");
} else {
@exec("ifconfig", $mac);
$mac = implode("\n", $mac);
if (preg_match_all("#HWaddr[ \t]{1,}([0-9a-f:]{17})#", $mac, $matches)) {
foreach ($matches[1] as $i => $v) {
if ($v == "00:00:00:00:00:00") {
unset($matches[1][$i]);
}
}
$machine .= implode(" ", $matches[1]);
//Mac Addresses
}
}
} elseif ($os === "android") {
$machine .= @file_get_contents("/system/build.prop");
} elseif ($os === "mac") {
$machine .= `system_profiler SPHardwareDataType | grep UUID`;
}
$data = $machine . PHP_MAXPATHLEN;
$data .= PHP_INT_MAX;
$data .= PHP_INT_SIZE;
$data .= get_current_user();
foreach (get_loaded_extensions() as $ext) {
$data .= $ext . ":" . phpversion($ext);
}
$uuid = UUID::fromData($machine, $data);
if ($extra === "") {
self::$serverUniqueId = $uuid;
}
return $uuid;
}
示例11: 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;
//.........这里部分代码省略.........
示例12: __construct
public function __construct(SourceInterface $interface, $clientID, $ip, $port)
{
parent::__construct($interface, $clientID, $ip, $port);
$this->randomUUID = UUID::fromRandom();
$this->inventory = new DummyInventory($this);
}
示例13: 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"));
//.........这里部分代码省略.........
示例14: 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;
}
//.........这里部分代码省略.........
示例15: 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);*/
}
}