mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 08:17:34 +00:00
Entity: added a guard to prevent __construct() from running multiple times
this typically happens due to flawed logic in child classes in plugins which causes parent::__construct() to get called multiple times.
This commit is contained in:
parent
a5dab0f61e
commit
2b8a54f8ff
@ -216,7 +216,13 @@ abstract class Entity{
|
||||
/** @var int|null */
|
||||
protected $targetId = null;
|
||||
|
||||
private bool $constructorCalled = false;
|
||||
|
||||
public function __construct(Location $location, ?CompoundTag $nbt = null){
|
||||
if($this->constructorCalled){
|
||||
throw new \LogicException("Attempted to call constructor for an Entity multiple times");
|
||||
}
|
||||
$this->constructorCalled = true;
|
||||
Utils::checkLocationNotInfOrNaN($location);
|
||||
|
||||
$this->timings = Timings::getEntityTimings($this);
|
||||
|
Loading…
x
Reference in New Issue
Block a user