How to get the World a Location object resides in

In Spigot, it is possible to get the current world of a location by using getWorld().

I am looking to do this in Sponge, but could not find this on the JavaDocs. Does anyone know if this is currently possible, and if so, how may I achieve this?

Returns the Extent the location is in (e.g. World or Chunk)

Thanks, so this should work?

final World w = (World) loc.getExtent()

Location is generic on the Extent, so you shouldn’t need to cast as long as you have a Location<World> object. It’s bad practice to deal with generic types in a raw fashion.