mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-12 06:25:32 +00:00
Human: do not modify totalXp unless setting XP succeeds
This commit is contained in:
parent
42171f6e06
commit
52f734799e
@ -400,14 +400,14 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
|||||||
* @param bool $playSound Whether to play level-up and XP gained sounds.
|
* @param bool $playSound Whether to play level-up and XP gained sounds.
|
||||||
*/
|
*/
|
||||||
public function addXp(int $amount, bool $playSound = true) : bool{
|
public function addXp(int $amount, bool $playSound = true) : bool{
|
||||||
if($amount > 0){
|
|
||||||
$this->totalXp += $amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
$oldLevel = $this->getXpLevel();
|
$oldLevel = $this->getXpLevel();
|
||||||
$oldTotal = $this->getCurrentTotalXp();
|
$oldTotal = $this->getCurrentTotalXp();
|
||||||
|
|
||||||
if($this->setCurrentTotalXp($oldTotal + $amount)){
|
if($this->setCurrentTotalXp($oldTotal + $amount)){
|
||||||
|
if($amount > 0){
|
||||||
|
$this->totalXp += $amount;
|
||||||
|
}
|
||||||
|
|
||||||
if($playSound){
|
if($playSound){
|
||||||
$newLevel = $this->getXpLevel();
|
$newLevel = $this->getXpLevel();
|
||||||
if((int) ($newLevel / 5) > (int) ($oldLevel / 5)){
|
if((int) ($newLevel / 5) > (int) ($oldLevel / 5)){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user