Human: limit lifetime total XP range to INT32_MAX

closes #4484
This commit is contained in:
Dylan K. Taylor 2021-10-30 16:05:10 +01:00
parent 71f2a34616
commit 69952ae2af
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -475,8 +475,8 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
* score when they die. (TODO: add this when MCPE supports it)
*/
public function setLifetimeTotalXp(int $amount) : void{
if($amount < 0){
throw new \InvalidArgumentException("XP must be greater than 0");
if($amount < 0 || $amount > INT32_MAX){
throw new \InvalidArgumentException("XP must be greater than 0 and less than " . INT32_MAX);
}
$this->totalXp = $amount;