server.getServer().getSegments() should return an iterable of segments. You should not need to convert this to an array.