Use Server::getLevelByName("world") to get the Level instance, then use count(Level::getPlayers()) to get the number of players. PHP: /** @var Server $server */$levels = [];foreach(["world1", "world2"] as $worldname){ $levels[] = $server->getLevelByName($worldname);}$count = 0;foreach($levels as $level){ $count += count($level->getPlayers());}echo $count; Make sure the levels exist and are loaded.
This notation is a way to reference a method, not to say that you should write like that in code. It's written like this all over the PHP documentation actually, e.g. http://php.net/manual/en/reflection...refsect1-reflectionclass.getshortname-seealso