From 52f734799e99d5e45bd819e301ede0904f267193 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 16 Oct 2020 20:43:03 +0100 Subject: [PATCH] Human: do not modify totalXp unless setting XP succeeds --- src/pocketmine/entity/Human.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pocketmine/entity/Human.php b/src/pocketmine/entity/Human.php index b359d791eb..f44b46a335 100644 --- a/src/pocketmine/entity/Human.php +++ b/src/pocketmine/entity/Human.php @@ -400,14 +400,14 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ * @param bool $playSound Whether to play level-up and XP gained sounds. */ public function addXp(int $amount, bool $playSound = true) : bool{ - if($amount > 0){ - $this->totalXp += $amount; - } - $oldLevel = $this->getXpLevel(); $oldTotal = $this->getCurrentTotalXp(); if($this->setCurrentTotalXp($oldTotal + $amount)){ + if($amount > 0){ + $this->totalXp += $amount; + } + if($playSound){ $newLevel = $this->getXpLevel(); if((int) ($newLevel / 5) > (int) ($oldLevel / 5)){