This solution isn't ideal, but it works...
This commit is contained in:
Dylan K. Taylor 2017-08-23 13:19:18 +01:00
parent 0f2ca99c67
commit 84c8ac03fb
2 changed files with 22 additions and 3 deletions

View File

@ -1770,7 +1770,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
return; return;
} }
foreach($this->server->getOnlinePlayers() as $p){ foreach($this->server->getLoggedInPlayers() as $p){
if($p !== $this and $p->iusername === $this->iusername){ if($p !== $this and $p->iusername === $this->iusername){
if($p->kick("logged in from another location") === false){ if($p->kick("logged in from another location") === false){
$this->close($this->getLeaveMessage(), "Logged in from another location"); $this->close($this->getLeaveMessage(), "Logged in from another location");
@ -1827,6 +1827,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
$this->sendPlayStatus(PlayStatusPacket::LOGIN_SUCCESS); $this->sendPlayStatus(PlayStatusPacket::LOGIN_SUCCESS);
$this->loggedIn = true; $this->loggedIn = true;
$this->server->onPlayerLogin($this);
$pk = new ResourcePacksInfoPacket(); $pk = new ResourcePacksInfoPacket();
$manager = $this->server->getResourceManager(); $manager = $this->server->getResourceManager();
@ -1910,8 +1911,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
} }
$this->server->addOnlinePlayer($this); $this->server->addOnlinePlayer($this);
$this->server->onPlayerCompleteLoginSequence($this);
$this->server->onPlayerLogin($this);
} }
public function handleLogin(LoginPacket $packet) : bool{ public function handleLogin(LoginPacket $packet) : bool{
@ -3467,6 +3467,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
$this->loadQueue = []; $this->loadQueue = [];
if($this->loggedIn){ if($this->loggedIn){
$this->server->onPlayerLogout($this);
foreach($this->server->getOnlinePlayers() as $player){ foreach($this->server->getOnlinePlayers() as $player){
if(!$player->canSee($this)){ if(!$player->canSee($this)){
$player->showPlayer($this); $player->showPlayer($this);

View File

@ -254,6 +254,9 @@ class Server{
/** @var Player[] */ /** @var Player[] */
private $players = []; private $players = [];
/** @var Player[] */
private $loggedInPlayers = [];
/** @var Player[] */ /** @var Player[] */
private $playerList = []; private $playerList = [];
@ -689,6 +692,13 @@ class Server{
return $this->commandMap; return $this->commandMap;
} }
/**
* @return Player[]
*/
public function getLoggedInPlayers() : array{
return $this->loggedInPlayers;
}
/** /**
* @return Player[] * @return Player[]
*/ */
@ -2235,10 +2245,18 @@ class Server{
$this->uniquePlayers[$player->getRawUniqueId()] = $player->getRawUniqueId(); $this->uniquePlayers[$player->getRawUniqueId()] = $player->getRawUniqueId();
} }
$this->loggedInPlayers[$player->getRawUniqueId()] = $player;
}
public function onPlayerCompleteLoginSequence(Player $player){
$this->sendFullPlayerListData($player); $this->sendFullPlayerListData($player);
$player->dataPacket($this->craftingManager->getCraftingDataPacket()); $player->dataPacket($this->craftingManager->getCraftingDataPacket());
} }
public function onPlayerLogout(Player $player){
unset($this->loggedInPlayers[$player->getRawUniqueId()]);
}
public function addPlayer($identifier, Player $player){ public function addPlayer($identifier, Player $player){
$this->players[$identifier] = $player; $this->players[$identifier] = $player;
$this->identifiers[spl_object_hash($player)] = $identifier; $this->identifiers[spl_object_hash($player)] = $identifier;