diff --git a/src/API/ConsoleAPI.php b/src/API/ConsoleAPI.php index 35ea546c0..c511feb7c 100644 --- a/src/API/ConsoleAPI.php +++ b/src/API/ConsoleAPI.php @@ -195,9 +195,8 @@ class ConsoleAPI{ } $cmd = strtolower(substr($line, 0, $end)); $params = (string) substr($line, $end + 1); - if(isset($this->alias[$cmd])){ - return $this->run($this->alias[$cmd] . " " .$params, $issuer, $cmd); + return $this->run($this->alias[$cmd] . ($params !== "" ? " " .$params:""), $issuer, $cmd); } if($issuer instanceof Player){ console("[DEBUG] \x1b[33m".$issuer->username."\x1b[0m issued server command: ".ltrim("$alias ")."/$cmd ".$params, true, true, 2); diff --git a/src/API/LevelAPI.php b/src/API/LevelAPI.php index 98fa1c79e..e1967c942 100644 --- a/src/API/LevelAPI.php +++ b/src/API/LevelAPI.php @@ -86,6 +86,9 @@ class LevelAPI{ } public function generateLevel($name, $seed = false, $generator = false){ + if($this->levelExists($name)){ + return false; + } $options = array(); if($this->server->api->getProperty("generator-settings") !== false and trim($this->server->api->getProperty("generator-settings")) != ""){ $options["preset"] = $this->server->api->getProperty("generator-settings"); @@ -101,19 +104,28 @@ class LevelAPI{ } $gen = new WorldGenerator($generator, $name, $seed === false ? Utils::readInt(Utils::getRandomBytes(4, false)):(int) $seed); $gen->generate(); + return true; } - public function loadLevel($name){ - if($this->get($name) !== false){ - return true; - } + public function levelExists($name){ $path = DATA_PATH."worlds/".$name."/"; - if(!file_exists($path."level.pmf")){ + if($this->get($name) === false and !file_exists($path."level.pmf")){ $level = new LevelImport($path); if($level->import() === false){ return false; } } + return true; + } + + public function loadLevel($name){ + if($this->get($name) !== false){ + return true; + }elseif($this->levelExists($name) === false){ + console("[NOTICE] Level \"".$name."\" not found"); + return false; + } + $path = DATA_PATH."worlds/".$name."/"; console("[INFO] Preparing level \"".$name."\""); $level = new PMFLevel($path."level.pmf"); $entities = new Config($path."entities.yml", CONFIG_YAML);