use this and replace $map with the variable name you are wanting to use , that should get the name of the world the player is in $map =$player->entity->level->getName();
How can i get players on defferent map? count($this->api->player->get("Creative") - Gived to me all count of all players on server.