mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-07 02:21:46 +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 */
|
/** @var int|null */
|
||||||
protected $targetId = null;
|
protected $targetId = null;
|
||||||
|
|
||||||
|
private bool $constructorCalled = false;
|
||||||
|
|
||||||
public function __construct(Location $location, ?CompoundTag $nbt = null){
|
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);
|
Utils::checkLocationNotInfOrNaN($location);
|
||||||
|
|
||||||
$this->timings = Timings::getEntityTimings($this);
|
$this->timings = Timings::getEntityTimings($this);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user