mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 16:51:42 +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 */
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user