mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-12 14:35:35 +00:00
Allow offline player data to be provided from a custom source
This commit is contained in:
parent
7745310870
commit
c05779314d
@ -576,20 +576,16 @@ class Server{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createPlayer(NetworkSession $session, PlayerInfo $playerInfo, bool $authenticated) : Player{
|
public function createPlayer(NetworkSession $session, PlayerInfo $playerInfo, bool $authenticated, ?CompoundTag $offlinePlayerData) : Player{
|
||||||
$ev = new PlayerCreationEvent($session);
|
$ev = new PlayerCreationEvent($session);
|
||||||
$ev->call();
|
$ev->call();
|
||||||
$class = $ev->getPlayerClass();
|
$class = $ev->getPlayerClass();
|
||||||
|
|
||||||
//TODO: make this async
|
|
||||||
//TODO: what about allowing this to be provided by PlayerCreationEvent?
|
|
||||||
$namedtag = $this->getOfflinePlayerData($playerInfo->getUsername());
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Player::__construct()
|
* @see Player::__construct()
|
||||||
* @var Player $player
|
* @var Player $player
|
||||||
*/
|
*/
|
||||||
$player = new $class($this, $session, $playerInfo, $authenticated, $namedtag);
|
$player = new $class($this, $session, $playerInfo, $authenticated, $offlinePlayerData);
|
||||||
return $player;
|
return $player;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,7 +229,11 @@ class NetworkSession{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function createPlayer() : void{
|
protected function createPlayer() : void{
|
||||||
$this->player = $this->server->createPlayer($this, $this->info, $this->authenticated);
|
//TODO: make this async
|
||||||
|
//TODO: what about allowing this to be provided by PlayerCreationEvent?
|
||||||
|
$offlinePlayerData = $this->server->getOfflinePlayerData($this->info->getUsername());
|
||||||
|
|
||||||
|
$this->player = $this->server->createPlayer($this, $this->info, $this->authenticated, $offlinePlayerData);
|
||||||
|
|
||||||
$this->invManager = new InventoryManager($this->player, $this);
|
$this->invManager = new InventoryManager($this->player, $this);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user