Class InviteManager
java.lang.Object
me.tayebyassine.homestead.managers.InviteManager
A utility class that manages
RegionInvite.-
Method Summary
Modifier and TypeMethodDescriptionstatic intRemoves all invites with invalid references:
- Players whose UUID no longer maps to a known player
- Regions that no longer existstatic intDeletes every invite in the cache.static intdeleteExpiredInvites(long maxAge) Deletes all invites older than the specified maximum age.static voiddeleteInvite(long id) Delete a player invitation.static voiddeleteInvitesOfPlayer(long regionId, org.bukkit.OfflinePlayer player) Deletes all invites sent by a region that invited a specific player.static voiddeleteInvitesOfPlayer(UUID playerId) Deletes all invites that invited a specific player.static voiddeleteInvitesOfPlayer(Region region, org.bukkit.OfflinePlayer player) Deletes all invites sent by a region that invited a specific player.static voiddeleteInvitesOfPlayer(org.bukkit.OfflinePlayer player) Deletes all invites that invited a specific player.static voiddeleteInvitesOfRegion(long regionId) Deletes all invites created by a region.static voiddeleteInvitesOfRegion(Region region) Deletes all invites created by a region.static RegionInvitegetInvite(long id) Retrieves a specific invite by its unique ID.static RegionInviteRetrieves the invite for a specific player in a specific region using UUIDs.static RegionInviteRetrieves the invite for a specific player in a specific region.static intReturns the number of pending invites in the server.static intgetInviteCount(long regionId) Returns the number of pending invites for a region.static intgetInviteCount(Region region) Returns the number of pending invites for a region.static intgetInviteCountOfPlayer(org.bukkit.OfflinePlayer player) Returns the number of pending invites a player has across all regions.getInvitedPlayers(long regionId) Returns all unique player UUIDs that have been invited to a region.getInvitedPlayers(Region region) Returns all unique player UUIDs that have been invited to a region.static List<RegionInvite> getInvitesOfPlayer(UUID playerId) Returns a list of invites that invited a specific player.static List<RegionInvite> getInvitesOfPlayer(org.bukkit.OfflinePlayer player) Returns a list of invites that invited a specific player.static List<RegionInvite> getInvitesOfRegion(long regionId) Returns a list of invites created by a region.static List<RegionInvite> getInvitesOfRegion(Region region) Returns a list of invites created by a region.static List<RegionInvite> getRecentInvites(long regionId, int limit) Returns the most recent invites for a region, sorted newest first.static List<RegionInvite> getRecentInvites(Region region, int limit) Returns the most recent invites for a region, sorted newest first.getRegionsInvitedTo(UUID playerId) Returns all region IDs that a player has been invited to.getRegionsInvitedTo(org.bukkit.OfflinePlayer player) Returns all region IDs that a player has been invited to.static booleanhasPendingInvite(Region region, org.bukkit.OfflinePlayer player) Checks if a player has a pending invite from a region.static voidinvitePlayer(long regionId, org.bukkit.OfflinePlayer player) Invite a player to a region.static voidinvitePlayer(Region region, org.bukkit.OfflinePlayer player) Invite a player to a region.static booleanisInvited(long regionId, org.bukkit.OfflinePlayer player) Checks if a player is invited by a region.static booleanChecks if a player is invited by a region.static booleanisInviteExpired(RegionInvite invite, long maxAgeMillis) Checks if an invitation has expired based on a maximum age in milliseconds.
-
Method Details
-
invitePlayer
Invite a player to a region.- Parameters:
region- the regionplayer- the player
-
invitePlayer
public static void invitePlayer(long regionId, org.bukkit.OfflinePlayer player) Invite a player to a region.- Parameters:
regionId- the region IDplayer- the player
-
getInvite
Retrieves a specific invite by its unique ID.- Parameters:
id- the invite ID- Returns:
- the
RegionInvite, ornullif not found
-
getInvite
Retrieves the invite for a specific player in a specific region.- Parameters:
region- the regionplayer- the player- Returns:
- the
RegionInvite, ornullif not found
-
getInvite
Retrieves the invite for a specific player in a specific region using UUIDs.- Parameters:
regionId- the region IDplayerId- the player UUID- Returns:
- the
RegionInvite, ornullif not found
-
getInvitesOfRegion
Returns a list of invites created by a region.- Parameters:
region- the region- Returns:
- list of invites
-
getInvitesOfRegion
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
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
Returns a list of invites that invited a specific player.- Parameters:
player- the player- Returns:
- list of invites
-
getInvitesOfPlayer
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
-
getInvitedPlayers
-
getRegionsInvitedTo
-
getRegionsInvitedTo
-
getRecentInvites
Returns the most recent invites for a region, sorted newest first.- Parameters:
region- the regionlimit- maximum number of results- Returns:
- list of recent invites
-
getRecentInvites
Returns the most recent invites for a region, sorted newest first.- Parameters:
regionId- the region IDlimit- 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
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
Deletes all invites that invited a specific player.- Parameters:
playerId- the player UUID
-
deleteInvitesOfPlayer
Deletes all invites sent by a region that invited a specific player.- Parameters:
region- the regionplayer- 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 IDplayer- the player
-
isInvited
Checks if a player is invited by a region.- Parameters:
region- the regionplayer- the player- Returns:
trueif the player is invited,falseotherwise
-
isInvited
public static boolean isInvited(long regionId, org.bukkit.OfflinePlayer player) Checks if a player is invited by a region.- Parameters:
regionId- the region IDplayer- the player- Returns:
trueif the player is invited,falseotherwise
-
hasPendingInvite
Checks if a player has a pending invite from a region. This is an alias forisInvited(Region, OfflinePlayer)for semantic clarity.- Parameters:
region- the regionplayer- the player- Returns:
trueif a pending invite exists
-
isInviteExpired
Checks if an invitation has expired based on a maximum age in milliseconds.- Parameters:
invite- the invitemaxAgeMillis- maximum age in milliseconds- Returns:
trueif 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
-