Class InviteManager

java.lang.Object
me.tayebyassine.homestead.managers.InviteManager

public final class InviteManager extends Object
A utility class that manages RegionInvite.
  • Method Details

    • invitePlayer

      public static void invitePlayer(Region region, org.bukkit.OfflinePlayer player)
      Invite a player to a region.
      Parameters:
      region - the region
      player - the player
    • invitePlayer

      public static void invitePlayer(long regionId, org.bukkit.OfflinePlayer player)
      Invite a player to a region.
      Parameters:
      regionId - the region ID
      player - the player
    • getInvite

      public static RegionInvite getInvite(long id)
      Retrieves a specific invite by its unique ID.
      Parameters:
      id - the invite ID
      Returns:
      the RegionInvite, or null if not found
    • getInvite

      public static RegionInvite getInvite(Region region, org.bukkit.OfflinePlayer player)
      Retrieves the invite for a specific player in a specific region.
      Parameters:
      region - the region
      player - the player
      Returns:
      the RegionInvite, or null if not found
    • getInvite

      public static RegionInvite getInvite(long regionId, UUID playerId)
      Retrieves the invite for a specific player in a specific region using UUIDs.
      Parameters:
      regionId - the region ID
      playerId - the player UUID
      Returns:
      the RegionInvite, or null if not found
    • getInvitesOfRegion

      public static List<RegionInvite> getInvitesOfRegion(Region region)
      Returns a list of invites created by a region.
      Parameters:
      region - the region
      Returns:
      list of invites
    • getInvitesOfRegion

      public static List<RegionInvite> getInvitesOfRegion(long regionId)
      Returns a list of invites created by a region.
      Parameters:
      regionId - the region ID
      Returns:
      list of invites
    • getInviteCount

      public static int getInviteCount()
      Returns the number of pending invites in the server.
      Returns:
      the invite count
    • getInviteCount

      public static int getInviteCount(Region region)
      Returns the number of pending invites for a region.
      Parameters:
      region - the region
      Returns:
      the invite count
    • getInviteCount

      public static int getInviteCount(long regionId)
      Returns the number of pending invites for a region.
      Parameters:
      regionId - the region ID
      Returns:
      the invite count
    • getInvitesOfPlayer

      public static List<RegionInvite> getInvitesOfPlayer(org.bukkit.OfflinePlayer player)
      Returns a list of invites that invited a specific player.
      Parameters:
      player - the player
      Returns:
      list of invites
    • getInvitesOfPlayer

      public static List<RegionInvite> getInvitesOfPlayer(UUID playerId)
      Returns a list of invites that invited a specific player.
      Parameters:
      playerId - the player UUID
      Returns:
      list of invites
    • getInviteCountOfPlayer

      public static int getInviteCountOfPlayer(org.bukkit.OfflinePlayer player)
      Returns the number of pending invites a player has across all regions.
      Parameters:
      player - the player
      Returns:
      the invite count
    • getInvitedPlayers

      public static List<UUID> getInvitedPlayers(Region region)
      Returns all unique player UUIDs that have been invited to a region.
      Parameters:
      region - the region
      Returns:
      list of player UUIDs
    • getInvitedPlayers

      public static List<UUID> getInvitedPlayers(long regionId)
      Returns all unique player UUIDs that have been invited to a region.
      Parameters:
      regionId - the region ID
      Returns:
      list of player UUIDs
    • getRegionsInvitedTo

      public static List<Long> getRegionsInvitedTo(org.bukkit.OfflinePlayer player)
      Returns all region IDs that a player has been invited to.
      Parameters:
      player - the player
      Returns:
      list of region IDs
    • getRegionsInvitedTo

      public static List<Long> getRegionsInvitedTo(UUID playerId)
      Returns all region IDs that a player has been invited to.
      Parameters:
      playerId - the player UUID
      Returns:
      list of region IDs
    • getRecentInvites

      public static List<RegionInvite> getRecentInvites(Region region, int limit)
      Returns the most recent invites for a region, sorted newest first.
      Parameters:
      region - the region
      limit - maximum number of results
      Returns:
      list of recent invites
    • getRecentInvites

      public static List<RegionInvite> getRecentInvites(long regionId, int limit)
      Returns the most recent invites for a region, sorted newest first.
      Parameters:
      regionId - the region ID
      limit - maximum number of results
      Returns:
      list of recent invites
    • deleteInvite

      public static void deleteInvite(long id)
      Delete a player invitation.
      Parameters:
      id - the invite ID
    • deleteInvitesOfRegion

      public static void deleteInvitesOfRegion(Region region)
      Deletes all invites created by a region.
      Parameters:
      region - the region
    • deleteInvitesOfRegion

      public static void deleteInvitesOfRegion(long regionId)
      Deletes all invites created by a region.
      Parameters:
      regionId - the region ID
    • deleteInvitesOfPlayer

      public static void deleteInvitesOfPlayer(org.bukkit.OfflinePlayer player)
      Deletes all invites that invited a specific player.
      Parameters:
      player - the player
    • deleteInvitesOfPlayer

      public static void deleteInvitesOfPlayer(UUID playerId)
      Deletes all invites that invited a specific player.
      Parameters:
      playerId - the player UUID
    • deleteInvitesOfPlayer

      public static void deleteInvitesOfPlayer(Region region, org.bukkit.OfflinePlayer player)
      Deletes all invites sent by a region that invited a specific player.
      Parameters:
      region - the region
      player - the player
    • deleteInvitesOfPlayer

      public static void deleteInvitesOfPlayer(long regionId, org.bukkit.OfflinePlayer player)
      Deletes all invites sent by a region that invited a specific player.
      Parameters:
      regionId - the region ID
      player - the player
    • isInvited

      public static boolean isInvited(Region region, org.bukkit.OfflinePlayer player)
      Checks if a player is invited by a region.
      Parameters:
      region - the region
      player - the player
      Returns:
      true if the player is invited, false otherwise
    • isInvited

      public static boolean isInvited(long regionId, org.bukkit.OfflinePlayer player)
      Checks if a player is invited by a region.
      Parameters:
      regionId - the region ID
      player - the player
      Returns:
      true if the player is invited, false otherwise
    • hasPendingInvite

      public static boolean hasPendingInvite(Region region, org.bukkit.OfflinePlayer player)
      Checks if a player has a pending invite from a region. This is an alias for isInvited(Region, OfflinePlayer) for semantic clarity.
      Parameters:
      region - the region
      player - the player
      Returns:
      true if a pending invite exists
    • isInviteExpired

      public static boolean isInviteExpired(RegionInvite invite, long maxAgeMillis)
      Checks if an invitation has expired based on a maximum age in milliseconds.
      Parameters:
      invite - the invite
      maxAgeMillis - maximum age in milliseconds
      Returns:
      true if the invite is older than the specified age
    • deleteExpiredInvites

      public static int deleteExpiredInvites(long maxAge)
      Deletes all invites older than the specified maximum age.
      Parameters:
      maxAge - maximum age in seconds
      Returns:
      the number of deleted invites
    • deleteAllInvites

      public static int deleteAllInvites()
      Deletes every invite in the cache. Use with caution.
      Returns:
      the number of deleted invites
    • cleanupInvalidInvites

      public static int cleanupInvalidInvites()
      Removes all invites with invalid references:
      - Players whose UUID no longer maps to a known player
      - Regions that no longer exist
      Returns:
      number of corrupted invites removed