本文整理汇总了PHP中pocketmine\Player::close方法的典型用法代码示例。如果您正苦于以下问题:PHP Player::close方法的具体用法?PHP Player::close怎么用?PHP Player::close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\Player
的用法示例。
在下文中一共展示了Player::close方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: close
public function close(Player $player, $reason = "unknown reason")
{
if ($player instanceof DummyReceiver) {
if ($player->entity instanceof DummyEntity) {
$player->entity->close();
}
$player->close();
}
$this->sessions->detach($player);
unset($this->ackStore[$player->getName()]);
unset($this->replyStore[$player->getName()]);
}
示例2: close
public function close($message = "", $reason = "generic reason")
{
if ($this->bigBrother_status === 0) {
$pk = new LoginDisconnectPacket();
$pk->reason = TextFormat::toJSON($reason === "" ? "You have been disconnected." : $reason);
$this->putRawPacket($pk);
} else {
$pk = new PlayDisconnectPacket();
$pk->reason = TextFormat::toJSON($reason === "" ? "You have been disconnected." : $reason);
$this->putRawPacket($pk);
}
parent::close($message, $reason);
}
示例3: processLogin
public function processLogin(Player $player, CompoundTag $nbt)
{
if (!$this->server->isWhitelisted(strtolower($player->getName()))) {
$player->close($player->getLeaveMessage(), "Server is white-listed");
return;
} elseif ($this->server->getNameBans()->isBanned(strtolower($player->getName())) or $this->server->getIPBans()->isBanned($player->getAddress())) {
$player->close($player->getLeaveMessage(), "You are banned");
return;
}
if ($player->hasPermission(Server::BROADCAST_CHANNEL_USERS)) {
$this->server->getPluginManager()->subscribeToPermission(Server::BROADCAST_CHANNEL_USERS, $player);
}
if ($player->hasPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE)) {
$this->server->getPluginManager()->subscribeToPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE, $player);
}
foreach ($this->server->getOnlinePlayers() as $p) {
if ($p !== $player and strtolower($p->getName()) === strtolower($player->getName())) {
if ($p->kick("logged in from another location") === false) {
$player->close($player->getLeaveMessage(), "Logged in from another location");
return;
}
} elseif ($p->loggedIn and $player->getUniqueId()->equals($p->getUniqueId())) {
if ($p->kick("logged in from another location") === false) {
$player->close($player->getLeaveMessage(), "Logged in from another location");
return;
}
}
}
// $nbt = $player->server->getOfflinePlayerData ( $this->username );
if (!isset($nbt->NameTag)) {
$nbt->NameTag = new StringTag("NameTag", $this->getPrivateVariableData($player, 'username'));
} else {
$nbt["NameTag"] = $this->getPrivateVariableData($player, 'username');
}
$player->gamemode = $nbt["playerGameType"] & 0x3;
if ($this->server->getForceGamemode()) {
$player->gamemode = $this->server->getGamemode();
$nbt->playerGameType = new IntTag("playerGameType", $player->gamemode);
}
// $player->allowFlight = $player->isCreative ();
$this->setPrivateVariableData($player, 'allowFlight', $player->isCreative());
if (($level = $this->server->getLevelByName($nbt["Level"])) === null) {
$player->setLevel($this->server->getDefaultLevel());
$nbt["Level"] = $this->level->getName();
$nbt["Pos"][0] = $player->level->getSpawnLocation()->x;
$nbt["Pos"][1] = $player->level->getSpawnLocation()->y;
$nbt["Pos"][2] = $player->level->getSpawnLocation()->z;
} else {
$player->setLevel($level);
}
if (!$nbt instanceof CompoundTag) {
$player->close($player->getLeaveMessage(), "Invalid data");
return;
}
$player->achievements = [];
/** @var Byte $achievement */
foreach ($nbt->Achievements as $achievement) {
$player->achievements[$achievement->getName()] = $achievement->getValue() > 0 ? true : false;
}
$nbt->lastPlayed = new LongTag("lastPlayed", floor(microtime(true) * 1000));
if ($this->server->getAutoSave()) {
$this->server->saveOfflinePlayerData($player->getName(), $nbt, true);
}
// parent::__construct ( $this->level->getChunk ( $nbt ["Pos"] [0] >> 4, $nbt ["Pos"] [2] >> 4, true ), $nbt );
$this->entityConstruct($player, $player->getLevel()->getChunk($nbt["Pos"][0] >> 4, $nbt["Pos"][2] >> 4, true), $nbt);
$player->loggedIn = true;
$this->server->addOnlinePlayer($player);
$this->server->getPluginManager()->callEvent($ev = new PlayerLoginEvent($player, "Plugin reason"));
if ($ev->isCancelled()) {
$player->close($player->getLeaveMessage(), $ev->getKickMessage());
return;
}
if ($player->isCreative()) {
$player->getInventory()->setHeldItemSlot(0);
} else {
$player->getInventory()->setHeldItemSlot($player->getInventory()->getHotbarSlotIndex(0));
}
$pk = new PlayStatusPacket();
$pk->status = PlayStatusPacket::LOGIN_SUCCESS;
$player->dataPacket($pk);
if ($this->getPrivateVariableData($player, 'spawnPosition') === null and isset($player->namedtag->SpawnLevel) and ($level = $this->server->getLevelByName($player->namedtag["SpawnLevel"])) instanceof Level) {
$this->setPrivateVariableData($player, 'spawnPosition', new Position($player->namedtag["SpawnX"], $player->namedtag["SpawnY"], $player->namedtag["SpawnZ"], $level));
}
$spawnPosition = $player->getSpawn();
$pk = new StartGamePacket();
$pk->seed = -1;
$pk->dimension = 0;
$pk->x = $player->x;
$pk->y = $player->y;
$pk->z = $player->z;
$pk->spawnX = (int) $spawnPosition->x;
$pk->spawnY = (int) $spawnPosition->y;
$pk->spawnZ = (int) $spawnPosition->z;
$pk->generator = 1;
// 0 old, 1 infinite, 2 flat
$pk->gamemode = $player->gamemode & 0x1;
$pk->eid = 0;
// Always use EntityID as zero for the actual player
$player->dataPacket($pk);
$pk = new SetTimePacket();
//.........这里部分代码省略.........