Fixed Level::nextSave

This commit is contained in:
Shoghi Cervantes Pueyo 2013-05-16 17:07:28 +02:00
parent 9a3f887f44
commit 3cc4546f93
2 changed files with 41 additions and 38 deletions

View File

@ -37,11 +37,11 @@ class PlayerAPI{
$this->server->api->console->register("list", "", array($this, "commandHandler")); $this->server->api->console->register("list", "", array($this, "commandHandler"));
$this->server->api->console->register("kill", "<player>", array($this, "commandHandler")); $this->server->api->console->register("kill", "<player>", array($this, "commandHandler"));
$this->server->api->console->register("gamemode", "<mode> [player]", array($this, "commandHandler")); $this->server->api->console->register("gamemode", "<mode> [player]", array($this, "commandHandler"));
$this->server->api->console->register("tppos", "[target player] <x> <y> <z>", array($this, "commandHandler")); $this->server->api->console->register("tp", "[target player] <destination player> OR [target player] <x> <y> <z>", array($this, "commandHandler"));
$this->server->api->console->register("tp", "[target player] <destination player>", array($this, "commandHandler"));
$this->server->api->console->register("spawn", "[world]", array($this, "commandHandler")); $this->server->api->console->register("spawn", "[world]", array($this, "commandHandler"));
$this->server->api->console->register("lag", "", array($this, "commandHandler")); $this->server->api->console->register("lag", "", array($this, "commandHandler"));
$this->server->api->console->alias("suicide", "kill"); $this->server->api->console->alias("suicide", "kill");
$this->server->api->console->alias("tppos", "tp");
$this->server->api->ban->cmdWhitelist("list"); $this->server->api->ban->cmdWhitelist("list");
$this->server->api->ban->cmdWhitelist("lag"); $this->server->api->ban->cmdWhitelist("lag");
} }
@ -178,41 +178,42 @@ class PlayerAPI{
} }
break; break;
case "tp": case "tp":
if(!isset($params[1]) and isset($params[0]) and ($issuer instanceof Player)){ if(count($params) <= 2){
$name = $issuer->username; if(!isset($params[1]) and isset($params[0]) and ($issuer instanceof Player)){
$target = $params[1]; $name = $issuer->username;
}elseif(isset($params[1]) and isset($params[0])){ $target = $params[1];
$name = $params[0]; }elseif(isset($params[1]) and isset($params[0])){
$target = $params[1]; $name = $params[0];
$target = $params[1];
}else{
$output .= "Usage: /$cmd [target player] <destination player>\n";
break;
}
if($this->teleport($name, $target)){
$output .= "\"$name\" teleported to \"$target\"\n";
}else{
$output .= "Couldn't teleport.\n";
}
}else{ }else{
$output .= "Usage: /$cmd [target player] <destination player>\n"; if(!isset($params[3]) and isset($params[2]) and isset($params[1]) and isset($params[0]) and ($issuer instanceof Player)){
break; $name = $issuer->username;
} $x = (float) $params[0];
if($this->teleport($name, $target)){ $y = (float) $params[1];
$output .= "\"$name\" teleported to \"$target\"\n"; $z = (float) $params[2];
}else{ }elseif(isset($params[3]) and isset($params[2]) and isset($params[1]) and isset($params[0])){
$output .= "Couldn't teleport.\n"; $name = $params[0];
} $x = (float) $params[1];
break; $y = (float) $params[2];
case "tppos": $z = (float) $params[3];
if(!isset($params[3]) and isset($params[2]) and isset($params[1]) and isset($params[0]) and ($issuer instanceof Player)){ }else{
$name = $issuer->username; $output .= "Usage: /$cmd [player] <x> <y> <z>\n";
$x = (float) $params[0]; break;
$y = (float) $params[1]; }
$z = (float) $params[2]; if($this->tppos($name, $x, $y, $z)){
}elseif(isset($params[3]) and isset($params[2]) and isset($params[1]) and isset($params[0])){ $output .= "\"$name\" teleported to ($x, $y, $z)\n";
$name = $params[0]; }else{
$x = (float) $params[1]; $output .= "Couldn't teleport.\n";
$y = (float) $params[2]; }
$z = (float) $params[3];
}else{
$output .= "Usage: /$cmd [player] <x> <y> <z>\n";
break;
}
if($this->tppos($name, $x, $y, $z)){
$output .= "\"$name\" teleported to ($x, $y, $z)\n";
}else{
$output .= "Couldn't teleport.\n";
} }
break; break;
case "kill": case "kill":
@ -246,7 +247,9 @@ class PlayerAPI{
$player = $this->get($target); $player = $this->get($target);
if(($player instanceof Player) and ($player->entity instanceof Entity)){ if(($player instanceof Player) and ($player->entity instanceof Entity)){
$target = $player->username; $target = $player->username;
return $this->tppos($name, $player->entity->x, $player->entity->y, $player->entity->z); $origin = $this->get($name);
$name = $origin->username;
return $origin->teleport($player->entity);
} }
return false; return false;
} }

View File

@ -158,7 +158,7 @@ class Level{
$this->level->setData("time", (int) $this->time); $this->level->setData("time", (int) $this->time);
$this->level->doSaveRound(); $this->level->doSaveRound();
$this->level->saveData(); $this->level->saveData();
$this->lastSave = microtime(true) + 90; $this->nextSave = microtime(true) + 90;
} }
public function getBlock(Vector3 $pos){ public function getBlock(Vector3 $pos){