mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-11 05:55:33 +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 */
|
/** @var bool */
|
||||||
protected $closed = false;
|
protected $closed = false;
|
||||||
|
private bool $closeInFlight = false;
|
||||||
/** @var bool */
|
/** @var bool */
|
||||||
private $needsDespawn = false;
|
private $needsDespawn = false;
|
||||||
|
|
||||||
@ -1518,12 +1519,18 @@ abstract class Entity{
|
|||||||
* WARNING: Entities are unusable after this has been executed!
|
* WARNING: Entities are unusable after this has been executed!
|
||||||
*/
|
*/
|
||||||
final public function close() : void{
|
final public function close() : void{
|
||||||
|
if($this->closeInFlight){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(!$this->closed){
|
if(!$this->closed){
|
||||||
$this->closed = true;
|
$this->closeInFlight = true;
|
||||||
(new EntityDespawnEvent($this))->call();
|
(new EntityDespawnEvent($this))->call();
|
||||||
|
|
||||||
$this->onDispose();
|
$this->onDispose();
|
||||||
|
$this->closed = true;
|
||||||
$this->destroyCycles();
|
$this->destroyCycles();
|
||||||
|
$this->closeInFlight = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user