mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-15 16:05:28 +00:00
Implement a locking variable to circumvent a infinite regression (#2901)
closes #2876
This commit is contained in:
parent
59334d652f
commit
c5498bb3fa
@ -562,6 +562,8 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
|
|||||||
/** @var bool */
|
/** @var bool */
|
||||||
protected $constructed = false;
|
protected $constructed = false;
|
||||||
|
|
||||||
|
/** @var bool */
|
||||||
|
private $closeInFlight = false;
|
||||||
|
|
||||||
public function __construct(Level $level, CompoundTag $nbt){
|
public function __construct(Level $level, CompoundTag $nbt){
|
||||||
$this->constructed = true;
|
$this->constructed = true;
|
||||||
@ -2109,7 +2111,12 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
|
|||||||
* WARNING: Entities are unusable after this has been executed!
|
* WARNING: Entities are unusable after this has been executed!
|
||||||
*/
|
*/
|
||||||
public function close() : void{
|
public function close() : void{
|
||||||
|
if($this->closeInFlight){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(!$this->closed){
|
if(!$this->closed){
|
||||||
|
$this->closeInFlight = true;
|
||||||
(new EntityDespawnEvent($this))->call();
|
(new EntityDespawnEvent($this))->call();
|
||||||
$this->closed = true;
|
$this->closed = true;
|
||||||
|
|
||||||
@ -2128,6 +2135,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
|
|||||||
|
|
||||||
$this->namedtag = null;
|
$this->namedtag = null;
|
||||||
$this->lastDamageCause = null;
|
$this->lastDamageCause = null;
|
||||||
|
$this->closeInFlight = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user