本文整理汇总了PHP中pocketmine\Player::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP Player::getId方法的具体用法?PHP Player::getId怎么用?PHP Player::getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\Player
的用法示例。
在下文中一共展示了Player::getId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: internal_onQuit
private function internal_onQuit(Player $player)
{
if (isset($this->sessions[$player->getId()])) {
$this->sessions[$player->getId()]->close();
unset($this->sessions[$player->getId()]);
}
}
示例2: __construct
public function __construct(FullChunk $chunk, CompoundTag $nbt, Player $owner = null)
{
if ($owner == null) {
$this->close();
return;
}
parent::__construct($chunk, $nbt);
$this->owner = $owner;
$this->setDataProperty(self::DATA_NO_AI, self::DATA_TYPE_BYTE, 1);
$this->setDataProperty(self::DATA_SOURCE_UUID, self::DATA_TYPE_LONG, $this->owner->getId());
$this->setDataProperty(self::DATA_TARGET_UUID, self::DATA_TYPE_LONG, $this->getId());
}
示例3: setMute
public function setMute(Player $player, $muted)
{
$sub = $this->playerSubs[$player->getId()];
$original = $sub->muted;
$sub->muted = $muted;
return $original;
}
示例4: private_onLogin
private function private_onLogin(Player $player)
{
/** @var string|LoginDataQuery $LoginQuery */
$LoginQuery = $this->main->getLoginQueryImpl();
/** @noinspection PhpDeprecationInspection */
new $LoginQuery($this->main, $player->getId(), $player->getName(), $player->getAddress(), $player->getClientId());
}
示例5: setFlaming
public function setFlaming(Player $target)
{
$flags = (int) $target->getDataProperty(Player::DATA_FLAGS);
$flags ^= 1 << Player::DATA_FLAG_ONFIRE;
$dataProperty = [Player::DATA_FLAGS => [Player::DATA_TYPE_BYTE, $flags]];
$pk = new SetEntityDataPacket();
$pk->eid = $target->getId();
$pk->metadata = $dataProperty;
Server::broadcastPacket($this->getPlayer()->getLevel()->getPlayers(), $pk->setChannel(Network::CHANNEL_WORLD_EVENTS));
}
示例6: onActivate
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
{
if (!$target instanceof Fence) {
return false;
}
foreach ($level->getChunkEntities($target->x >> 4, $target->z >> 4) as $entity) {
if ($entity->isLeashed()) {
if ($entity->leadHolder === $player->getId()) {
$nbt = new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $block->getX() + 0.5), new DoubleTag("", $block->getY()), new DoubleTag("", $block->getZ() + 0.5)]), "Motion" => new ListTag("Motion", [new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0)]), "Rotation" => new ListTag("Rotation", [new FloatTag("", lcg_value() * 360), new FloatTag("", 0)])]);
$level->addEntity($knot = new LeashKnot($level->getChunkAt($target->x >> 4, $target->z >> 4), $nbt));
$entity->setLeashHolder($knot);
}
}
}
}
示例7: __construct
public function __construct(HereAuth $main, Player $player, AccountInfo $info)
{
$this->loadTime = microtime(true);
$this->main = $main;
$this->player = $player;
$this->accountInfo = $info;
if (!$info->passwordHash) {
$main->getDataBase()->passesLimit($player->getAddress(), $main->getConfig()->getNested("Registration.RateLimit.Accounts", 3), $main->getConfig()->getNested("Registration.RateLimit.Days", 30) * 86400, $player->getId());
if (!$main->getConfig()->getNested("ForceRegister.Enabled", true)) {
// no registration involved
$this->onAuth();
$reminder = $main->getConfig()->getNested("ForceRegister.Reminder", "");
if (strlen($reminder) > 0) {
$player->sendMessage($reminder);
}
return;
}
$this->startRegistration();
$this->initAppearance();
return;
}
if (!$this->checkMultiFactor()) {
throw new \Exception("MFA failure");
}
if ($info->passwordHash[0] !== "{") {
if ($info->opts->autoSecret and $player->getClientSecret() === $info->lastSecret and $this->callLogin(HereAuthLoginEvent::METHOD_CLIENT_SECRET)) {
$this->main->getAuditLogger()->logLogin(strtolower($player->getName()), $player->getAddress(), "secret");
$this->onAuth();
return;
}
if ($info->opts->autoIp and $player->getAddress() === $info->lastIp and $this->callLogin(HereAuthLoginEvent::METHOD_IP)) {
$this->main->getAuditLogger()->logLogin(strtolower($player->getName()), $player->getAddress(), "ip");
$this->onAuth();
return;
}
if ($info->opts->autoUuid and $player->getUniqueId()->toBinary() === $info->lastUuid and $this->callLogin(HereAuthLoginEvent::METHOD_UUID)) {
$this->main->getAuditLogger()->logLogin(strtolower($player->getName()), $player->getAddress(), "uuid");
$this->onAuth();
return;
}
}
$this->state = self::STATE_PENDING_LOGIN;
$this->player->sendMessage($main->getMessages()->getNested("Login.Query", "Please login"));
$this->initAppearance();
}
示例8: getSession
public function getSession(Player $player)
{
return $this->sessions[$player->getId()];
}
示例9: hidePlayer
public function hidePlayer(Player $player)
{
$player->despawnFromAll();
$pk = new RemoveEntityPacket();
$pk->eid = $player->getId();
foreach ($player->getLevel()->getPlayers() as $p) {
$p->dataPacket($pk);
}
}
示例10: onActivate
public function onActivate(Item $item, Player $player = null)
{
if (($this->getDamage() & 0x8) === 0x8) {
//Top
$down = $this->getSide(0);
if ($down->getId() === $this->getId()) {
$meta = $down->getDamage() ^ 0x4;
$this->getLevel()->setBlock($down, Block::get($this->getId(), $meta), true);
$players = $this->getLevel()->getUsingChunk($this->x >> 4, $this->z >> 4);
if ($player instanceof Player) {
unset($players[$player->getId()]);
}
$this->level->addSound(new DoorSound($this));
return true;
}
return false;
} else {
$this->meta ^= 0x4;
$this->getLevel()->setBlock($this, $this, true);
$players = $this->getLevel()->getUsingChunk($this->x >> 4, $this->z >> 4);
if ($player instanceof Player) {
unset($players[$player->getId()]);
}
$this->level->addSound(new DoorSound($this));
}
return true;
}
示例11: getUserByPlayer
public function getUserByPlayer(Player $player)
{
$id = $player->getId();
return $this->users[$id] ?? null;
}
示例12: freeChunk
/**
* WARNING: Do not use this, it's only for internal use.
* Changes to this function won't be recorded on the version.
*
* @param int $X
* @param int $Z
* @param Player $player
*/
public function freeChunk($X, $Z, Player $player)
{
unset($this->usedChunks[$index = PHP_INT_SIZE === 8 ? ($X & 4294967295.0) << 32 | $Z & 4294967295.0 : $X . ":" . $Z][$player->getId()]);
$this->unloadChunkRequest($X, $Z, true);
}
示例13: despawnFrom
/**
* @param Player $player
*/
public function despawnFrom(Player $player)
{
if (isset($this->hasSpawned[$player->getId()])) {
$pk = new RemoveEntityPacket();
$pk->eid = $this->id;
$player->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING));
unset($this->hasSpawned[$player->getId()]);
}
}
示例14: getUserByPlayer
public function getUserByPlayer(Player $player)
{
$id = $player->getId();
return isset($this->users[$id]) ? $this->users[$id] : null;
}
示例15: freeChunk
/**
* WARNING: Do not use this, it's only for internal use.
* Changes to this function won't be recorded on the version.
*
* @param int $X
* @param int $Z
* @param Player $player
*/
public function freeChunk($X, $Z, Player $player)
{
unset($this->usedChunks[$index = Level::chunkHash($X, $Z)][$player->getId()]);
$this->unloadChunkRequest($X, $Z, true);
}