This function could be included in your PluginBase. You will have to import pocketmine\level\Level. PHP: public function levelExists($name){ return ($this->getServer()->getLevelByName($name) instanceof Level);}
Also, if a level is generated is not loaded, you should check its existence by $server->isLevelGenerated($name).