@GET @Path("/mail/{player}") @Permission({ "mail", "list" }) @ApiOperation(value = "List mail", notes = "Get a list of all mail messages of a player.") public Collection<CachedMailMessage> listMail( @PathParam("player") @ApiParam("The uuid of the player") CachedPlayer player) throws NotFoundException { Optional<NucleusMailService> optSrv = NucleusAPI.getMailService(); if (!optSrv.isPresent()) { throw new InternalServerErrorException("Nuclues mail service not available"); } NucleusMailService srv = optSrv.get(); Optional<User> optUser = player.getUser(); if (!optUser.isPresent()) { throw new InternalServerErrorException("Could not get user"); } return WebAPI.runOnMain( () -> srv.getMail(optUser.get(), mailMessage -> { return true; }).stream() .map(CachedMailMessage::new) .collect(Collectors.toList()) ); }