API 13 equivalent of ServerPlayerConnection#latency

Hi,

I develop a plugin that tracks a bunch of statistics and one of them is the ping reported by the minecraft server for each player. This field is usually latency or ping in the EntityPlayer class in the Minecraft code.

In API 8 this was accessed via ServerPlayerConnection by using ServerPlayer#connection method ServerPlayerConnection (SpongeAPI 8.0.0 API)

In API 13 ServerPlayer#connection returns ServerSideConnection which does not expose a latency field. ServerPlayer does not have latency field either. ServerSideConnection (SpongeAPI 13.0.0 API)

Where do I access latency? Do I need to make a mixin now or something to access it?

I can see it in ServerConnectionState.Game (SpongeAPI 13.0.0 API) but how do I get access to that one?

Discord had an answer

player.connection().state()
    .filter(e -> e instanceof ServerConnectionState.Game)
    .map(e -> (ServerConnectionState.Game) e)
    .map(ServerConnectionState.Game::latency).orElse(0);