diff --git a/src/API/PlayerAPI.php b/src/API/PlayerAPI.php index 3f6f19840..934a4ca05 100644 --- a/src/API/PlayerAPI.php +++ b/src/API/PlayerAPI.php @@ -247,6 +247,9 @@ class PlayerAPI{ }else{ $data = unserialize(file_get_contents(FILE_PATH."players/".$name.".dat")); } + if($this->server->gamemode === 1){ + $data["health"] = 20; + } $this->server->handle("api.player.offline.get", $data); return $data; } diff --git a/src/classes/world/Entity.php b/src/classes/world/Entity.php index e0bcb5286..b8ce3ee00 100644 --- a/src/classes/world/Entity.php +++ b/src/classes/world/Entity.php @@ -329,11 +329,11 @@ class Entity extends stdClass{ return $this->setHealth($this->getHealth() - ((int) $dmg), $cause); } - public function setHealth($health, $cause = ""){ + public function setHealth($health, $cause = "", $force = false){ $health = (int) $health; if($health < $this->health){ $dmg = $this->health - $health; - if(($this->dmgcounter[0] < microtime(true) or $this->dmgcounter[1] < $dmg) and !$this->dead){ + if(($this->gamemode === 0 or $force === true) and ($this->dmgcounter[0] < microtime(true) or $this->dmgcounter[1] < $dmg) and !$this->dead){ $this->dmgcounter = array(microtime(true) + 0.5, $dmg); }else{ return false; //Entity inmunity