class ChatCooldowns {

    public Optional<Integer> checkCooldown(UUID player) {
        return Optional.ofNullable(cooldowns.compute(player, (uuid, lastChatTime) -> {
            int now = currentTime();
            if (lastChatTime == null || now - lastChatTime >= cooldown) {
                return null;
            } else {

                return cooldown - (now - lastChatTime);
            }
        }));
    }

}