mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-06 11:57:10 +00:00
seal up resource pack completion callback visibility
This commit is contained in:
parent
6dd31cc3f5
commit
80680f15f4
@ -565,10 +565,12 @@ class NetworkSession{
|
||||
$this->sendDataPacket(PlayStatusPacket::create(PlayStatusPacket::LOGIN_SUCCESS));
|
||||
|
||||
$this->logger->debug("Initiating resource packs phase");
|
||||
$this->setHandler(new ResourcePacksPacketHandler($this, $this->server->getResourcePackManager()));
|
||||
$this->setHandler(new ResourcePacksPacketHandler($this, $this->server->getResourcePackManager(), function() : void{
|
||||
$this->onResourcePacksDone();
|
||||
}));
|
||||
}
|
||||
|
||||
public function onResourcePacksDone() : void{
|
||||
private function onResourcePacksDone() : void{
|
||||
$this->createPlayer();
|
||||
|
||||
$this->setHandler(new PreSpawnPacketHandler($this->server, $this->player, $this));
|
||||
|
@ -53,13 +53,22 @@ class ResourcePacksPacketHandler extends PacketHandler{
|
||||
private $session;
|
||||
/** @var ResourcePackManager */
|
||||
private $resourcePackManager;
|
||||
/**
|
||||
* @var \Closure
|
||||
* @phpstan-var \Closure() : void
|
||||
*/
|
||||
private $completionCallback;
|
||||
|
||||
/** @var bool[][] uuid => [chunk index => hasSent] */
|
||||
private $downloadedChunks = [];
|
||||
|
||||
public function __construct(NetworkSession $session, ResourcePackManager $resourcePackManager){
|
||||
/**
|
||||
* @phpstan-param \Closure() : void $completionCallback
|
||||
*/
|
||||
public function __construct(NetworkSession $session, ResourcePackManager $resourcePackManager, \Closure $completionCallback){
|
||||
$this->session = $session;
|
||||
$this->resourcePackManager = $resourcePackManager;
|
||||
$this->completionCallback = $completionCallback;
|
||||
}
|
||||
|
||||
public function setUp() : void{
|
||||
@ -124,7 +133,7 @@ class ResourcePacksPacketHandler extends PacketHandler{
|
||||
break;
|
||||
case ResourcePackClientResponsePacket::STATUS_COMPLETED:
|
||||
$this->session->getLogger()->debug("Resource packs sequence completed");
|
||||
$this->session->onResourcePacksDone();
|
||||
($this->completionCallback)();
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user