Anyone know how to fix this? ERROR: Code: [05:22:13] [Server thread/CRITICAL]: TypeError: "Argument 1 passed to bedwars\LevelManager::addLevel() must be an instance of pocketmine\level\Level, null given, called in phar:///home/minecraft/plugins/BedWars v1.3.phar/src/bedwars/commands/subcommands/LevelSubcommand.php on line 64" (EXCEPTION) in "plugins/BedWars v1.3.phar/src/bedwars/LevelManager" at line 138 CODE (LevelManager): PHP: /** * @param Level $level * @param string $levelName * @param null $data */ public function addLevel(Level $level, string $levelName, $data = null) { //Line 138 $data = is_array($data) ? $data : $this->defaultLevelData; $data["levelName"] = $level->getName(); $data["folderName"] = $level->getFolderName(); $data["name"] = $levelName; $this->levels[$levelName] = new BedWarsLevel($data); }} CODE (LevelSubcommand): PHP: case "add": if(!(count($args) > 2)) { $sender->sendMessage(BedWars::getPrefix()."§cUsage: §7/bw level add <level> <customLevelName>"); break; } if(!$this->getPlugin()->getServer()->isLevelGenerated($args[1])) { $sender->sendMessage(BedWars::getPrefix()."§cLevel {$args[1]} does not found!"); break; } if($this->getPlugin()->getLevelManager()->levelExists($args[2])) { $sender->sendMessage(BedWars::getPrefix()."§cLevel {$args[2]} is already added!"); break; } $this->getPlugin()->getLevelManager()->addLevel($this->getPlugin()->getServer()->getLevelByName($args[1]), $args[2]); // line 64 $sender->sendMessage(BedWars::getPrefix()."§aLevel {$args[2]} added!"); break;
PHP: $this->getPlugin()->getServer()->getLevelByName($args[1]); This returns null, does the level exist and is it loaded? PHP: Server->loadLevel($args[1]);