How can I get the players in a World?

So I’ve been messing around with the World object for a while, but I can’t find a way to get the Players in a world. Is that currently possible? According to the JavaDocs, this should work:

Collection getPlayers()
Gets an unmodifiable collection of Players currently in this world

However, when I do this, it does not work:

World world; world.getPlayers();

World world = Sponge.getServer().getWorld("world");
Collection<Player> players = world.getPlayers();

You’re trying to use getPlayers() on the w object, which does not exist, as you defined it as “world”.

My bad, I edited the question to reflect what was actually going on. the issue still occurs.

Resolved, using wrong Sponge type (using 4.1, when I thought I was using 5.1)