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

View File

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