Fixed creative mode damage

This commit is contained in:
Shoghi Cervantes Pueyo 2013-01-26 17:06:30 +01:00
parent 4b744d7af3
commit e1ce88c0ef
2 changed files with 5 additions and 2 deletions

View File

@ -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;
}

View File

@ -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