From 3cc4546f93199245560fbd0ac7a0588ce941ce40 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Pueyo Date: Thu, 16 May 2013 17:07:28 +0200 Subject: [PATCH] Fixed Level::nextSave --- src/API/PlayerAPI.php | 77 ++++++++++++++++++++++--------------------- src/world/Level.php | 2 +- 2 files changed, 41 insertions(+), 38 deletions(-) diff --git a/src/API/PlayerAPI.php b/src/API/PlayerAPI.php index 88b61e3424..e65333486b 100644 --- a/src/API/PlayerAPI.php +++ b/src/API/PlayerAPI.php @@ -37,11 +37,11 @@ class PlayerAPI{ $this->server->api->console->register("list", "", array($this, "commandHandler")); $this->server->api->console->register("kill", "", array($this, "commandHandler")); $this->server->api->console->register("gamemode", " [player]", array($this, "commandHandler")); - $this->server->api->console->register("tppos", "[target player] ", array($this, "commandHandler")); - $this->server->api->console->register("tp", "[target player] ", array($this, "commandHandler")); + $this->server->api->console->register("tp", "[target player] OR [target player] ", 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->alias("suicide", "kill"); + $this->server->api->console->alias("tppos", "tp"); $this->server->api->ban->cmdWhitelist("list"); $this->server->api->ban->cmdWhitelist("lag"); } @@ -178,41 +178,42 @@ class PlayerAPI{ } break; case "tp": - if(!isset($params[1]) and isset($params[0]) and ($issuer instanceof Player)){ - $name = $issuer->username; - $target = $params[1]; - }elseif(isset($params[1]) and isset($params[0])){ - $name = $params[0]; - $target = $params[1]; + if(count($params) <= 2){ + if(!isset($params[1]) and isset($params[0]) and ($issuer instanceof Player)){ + $name = $issuer->username; + $target = $params[1]; + }elseif(isset($params[1]) and isset($params[0])){ + $name = $params[0]; + $target = $params[1]; + }else{ + $output .= "Usage: /$cmd [target player] \n"; + break; + } + if($this->teleport($name, $target)){ + $output .= "\"$name\" teleported to \"$target\"\n"; + }else{ + $output .= "Couldn't teleport.\n"; + } }else{ - $output .= "Usage: /$cmd [target player] \n"; - break; - } - if($this->teleport($name, $target)){ - $output .= "\"$name\" teleported to \"$target\"\n"; - }else{ - $output .= "Couldn't teleport.\n"; - } - break; - case "tppos": - if(!isset($params[3]) and isset($params[2]) and isset($params[1]) and isset($params[0]) and ($issuer instanceof Player)){ - $name = $issuer->username; - $x = (float) $params[0]; - $y = (float) $params[1]; - $z = (float) $params[2]; - }elseif(isset($params[3]) and isset($params[2]) and isset($params[1]) and isset($params[0])){ - $name = $params[0]; - $x = (float) $params[1]; - $y = (float) $params[2]; - $z = (float) $params[3]; - }else{ - $output .= "Usage: /$cmd [player] \n"; - break; - } - if($this->tppos($name, $x, $y, $z)){ - $output .= "\"$name\" teleported to ($x, $y, $z)\n"; - }else{ - $output .= "Couldn't teleport.\n"; + if(!isset($params[3]) and isset($params[2]) and isset($params[1]) and isset($params[0]) and ($issuer instanceof Player)){ + $name = $issuer->username; + $x = (float) $params[0]; + $y = (float) $params[1]; + $z = (float) $params[2]; + }elseif(isset($params[3]) and isset($params[2]) and isset($params[1]) and isset($params[0])){ + $name = $params[0]; + $x = (float) $params[1]; + $y = (float) $params[2]; + $z = (float) $params[3]; + }else{ + $output .= "Usage: /$cmd [player] \n"; + break; + } + if($this->tppos($name, $x, $y, $z)){ + $output .= "\"$name\" teleported to ($x, $y, $z)\n"; + }else{ + $output .= "Couldn't teleport.\n"; + } } break; case "kill": @@ -246,7 +247,9 @@ class PlayerAPI{ $player = $this->get($target); if(($player instanceof Player) and ($player->entity instanceof Entity)){ $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; } diff --git a/src/world/Level.php b/src/world/Level.php index ff5a0ce9b4..b62cb52951 100644 --- a/src/world/Level.php +++ b/src/world/Level.php @@ -158,7 +158,7 @@ class Level{ $this->level->setData("time", (int) $this->time); $this->level->doSaveRound(); $this->level->saveData(); - $this->lastSave = microtime(true) + 90; + $this->nextSave = microtime(true) + 90; } public function getBlock(Vector3 $pos){