mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 08:17:34 +00:00
Entity: don't flag as closed until just before cycle destruction
this allows stuff that requires a non-cycle-destroyed state to still operate during onDispose().
This commit is contained in:
parent
c092a2e836
commit
69cb0ba1bb
@ -177,6 +177,7 @@ abstract class Entity{
|
||||
|
||||
/** @var bool */
|
||||
protected $closed = false;
|
||||
private bool $closeInFlight = false;
|
||||
/** @var bool */
|
||||
private $needsDespawn = false;
|
||||
|
||||
@ -1518,12 +1519,18 @@ abstract class Entity{
|
||||
* WARNING: Entities are unusable after this has been executed!
|
||||
*/
|
||||
final public function close() : void{
|
||||
if($this->closeInFlight){
|
||||
return;
|
||||
}
|
||||
|
||||
if(!$this->closed){
|
||||
$this->closed = true;
|
||||
$this->closeInFlight = true;
|
||||
(new EntityDespawnEvent($this))->call();
|
||||
|
||||
$this->onDispose();
|
||||
$this->closed = true;
|
||||
$this->destroyCycles();
|
||||
$this->closeInFlight = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user