From c5498bb3fa6130405eccca929c6463e1cd8d82ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Fa=C3=9Fbender?= Date: Fri, 3 May 2019 15:46:51 +0200 Subject: [PATCH] Implement a locking variable to circumvent a infinite regression (#2901) closes #2876 --- src/pocketmine/entity/Entity.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index a87296ed2..c76f617fd 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -562,6 +562,8 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ /** @var bool */ protected $constructed = false; + /** @var bool */ + private $closeInFlight = false; public function __construct(Level $level, CompoundTag $nbt){ $this->constructed = true; @@ -2109,7 +2111,12 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ * WARNING: Entities are unusable after this has been executed! */ public function close() : void{ + if($this->closeInFlight){ + return; + } + if(!$this->closed){ + $this->closeInFlight = true; (new EntityDespawnEvent($this))->call(); $this->closed = true; @@ -2128,6 +2135,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ $this->namedtag = null; $this->lastDamageCause = null; + $this->closeInFlight = false; } }