mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
Player: Account for the possibility of Level being null in switchLevel()
the Entity base also accounts for this, and assuming that this is automatically valid is causing lots of crashes. I am not sure of the circumstances under which this is suddenly becoming null, but this shouldn't assume that the level is valid nonetheless.
This commit is contained in:
parent
37b445f210
commit
601811f0f8
@ -923,9 +923,11 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
protected function switchLevel(Level $targetLevel) : bool{
|
||||
$oldLevel = $this->level;
|
||||
if(parent::switchLevel($targetLevel)){
|
||||
foreach($this->usedChunks as $index => $d){
|
||||
Level::getXZ($index, $X, $Z);
|
||||
$this->unloadChunk($X, $Z, $oldLevel);
|
||||
if($oldLevel !== null){
|
||||
foreach($this->usedChunks as $index => $d){
|
||||
Level::getXZ($index, $X, $Z);
|
||||
$this->unloadChunk($X, $Z, $oldLevel);
|
||||
}
|
||||
}
|
||||
|
||||
$this->usedChunks = [];
|
||||
|
Loading…
x
Reference in New Issue
Block a user