*/ class PlayerExperienceChangeEvent extends EntityEvent implements Cancellable{ use CancellableTrait; /** @var Human */ protected $entity; public function __construct( Human $player, private int $oldLevel, private float $oldProgress, private ?int $newLevel, private ?float $newProgress ){ $this->entity = $player; } public function getOldLevel() : int{ return $this->oldLevel; } public function getOldProgress() : float{ return $this->oldProgress; } /** * @return int|null null indicates no change */ public function getNewLevel() : ?int{ return $this->newLevel; } /** * @return float|null null indicates no change */ public function getNewProgress() : ?float{ return $this->newProgress; } public function setNewLevel(?int $newLevel) : void{ $this->newLevel = $newLevel; } public function setNewProgress(?float $newProgress) : void{ if($newProgress < 0.0 || $newProgress > 1.0){ throw new \InvalidArgumentException("XP progress must be in range 0-1"); } $this->newProgress = $newProgress; } }