content: package events.discordevents.guildinvitecreate;
  
  import events.discordevents.DiscordEvent;
  import events.discordevents.eventtypeabstracts.GuildInviteCreateAbstract;
  import modules.invitetracking.InviteTracking;
  import mysql.hibernate.EntityManagerWrapper;
  import mysql.modules.invitetracking.DBInviteTracking;
  import mysql.modules.invitetracking.GuildInvite;
  import mysql.modules.invitetracking.InviteTrackingData;
  import net.dv8tion.jda.api.events.guild.invite.GuildInviteCreateEvent;
  
  @DiscordEvent
  public class GuildInviteCreateInviteTracking extends GuildInviteCreateAbstract {
  
      @Override
      public boolean onGuildInviteCreate(GuildInviteCreateEvent event, EntityManagerWrapper entityManager) {
          InviteTrackingData inviteTrackingData = DBInviteTracking.getInstance().retrieve(event.getGuild().getIdLong());
          if (inviteTrackingData.isActive() && event.getInvite() != null && event.getInvite().getInviter() != null) {
              GuildInvite guildInvite = new GuildInvite(
                      event.getGuild().getIdLong(),
                      event.getCode(),
                      event.getInvite().getInviter().getIdLong(),
                      0,
                      InviteTracking.calculateMaxAgeOfInvite(event.getInvite())
              );
              inviteTrackingData.getGuildInvites().put(guildInvite.getCode(), guildInvite);
          }
          return true;
      }
  
  }
  