class Warn implements Punishment {

    @Override
    public PunishResult punish(PunishmentParameters punishmentParameters) {
        return punishmentService.punish(punishmentParameters, PunishmentType.WARN).ifPresent(punishmentRecord -> {
            PunishmentData punishmentData = dataProvider.getPunishmentsFor(punishmentRecord.getTarget().getUuid());
            if (punishmentData.getWarns() == warnThreshold) {
                ban.punish(punishmentParameters);
                punishmentData.setWarns(0);
            } else {
                punishmentData.setWarns(punishmentData.getWarns() + 1);
            }
            punishmentDataRepository.update(punishmentData);
        });

    }

}