Class BanManager
java.lang.Object
tfagaming.projects.minecraft.homestead.managers.BanManager
A utility class that manages
RegionBan.-
Method Summary
Modifier and TypeMethodDescriptionstatic voidBan a player from accessing to a region.static voidBan a player from accessing to a region.static intRemoves all ban entries with invalid references:
- Players whose UUID no longer maps to a known player
- Regions that no longer existReturns an immutable view of every loaded ban entry.static intReturns the number of active bans in the server.static intgetBanCount(long regionId) Returns the number of active bans in a region.static intgetBanCount(Region region) Returns the number of active bans in a region.static RegionBangetBannedPlayer(long regionId, UUID playerId) Returns an instance ofRegionBanof a banned player from a region using UUIDs only.static RegionBangetBannedPlayer(long regionId, org.bukkit.OfflinePlayer player) Returns an instance ofRegionBanof a banned player from a region.static RegionBangetBannedPlayer(Region region, org.bukkit.OfflinePlayer player) Returns an instance ofRegionBanof a banned player from a region.getBannedRegions(UUID playerId) Returns all regions that a player is currently banned from.getBannedRegions(org.bukkit.OfflinePlayer player) Returns all regions that a player is currently banned from.static StringgetBanReason(long regionId, org.bukkit.OfflinePlayer player) Returns the ban reason for a player in a region, ornullif not banned.static StringgetBanReason(Region region, org.bukkit.OfflinePlayer player) Returns the ban reason for a player in a region, ornullif not banned.getBansOfRegion(long regionId) Returns a list of banned players from a region.getBansOfRegion(Region region) Returns a list of banned players from a region.static longgetBanTime(long regionId, org.bukkit.OfflinePlayer player) Returns the timestamp when a player was banned from a region, or0if not banned.static longgetBanTime(Region region, org.bukkit.OfflinePlayer player) Returns the timestamp when a player was banned from a region, or0if not banned.getRecentBans(long regionId, int limit) Returns the most recent bans for a region, sorted newest first.getRecentBans(Region region, int limit) Returns the most recent bans for a region, sorted newest first.static booleanhasActiveBans(long regionId) Checks if a region has any active bans.static booleanhasActiveBans(Region region) Checks if a region has any active bans.static booleanChecks if a player is banned from a region using UUIDs only.static booleanisBanned(long regionId, org.bukkit.OfflinePlayer player) Checks if a player is currently being banned by a region.static booleanChecks if a player is currently being banned by a region.static voidunbanAllPlayers(long regionId) Unban all players from a region.static voidunbanAllPlayers(Region region) Unban all players from a region.static voidunbanPlayer(long regionId, UUID playerId) Unban a player using raw UUIDs (useful when the player is completely offline and no OfflinePlayer exists).static voidunbanPlayer(long regionId, org.bukkit.OfflinePlayer player) Unban a player.static voidunbanPlayer(Region region, org.bukkit.OfflinePlayer player) Unban a player.static booleanupdateBanReason(long regionId, org.bukkit.OfflinePlayer player, @Nullable String reason) Updates the ban reason for a player without recreating the ban entry.static booleanupdateBanReason(Region region, org.bukkit.OfflinePlayer player, @Nullable String reason) Updates the ban reason for a player without recreating the ban entry.
-
Method Details
-
banPlayer
public static void banPlayer(Region region, org.bukkit.OfflinePlayer player, @Nullable @Nullable String reason) Ban a player from accessing to a region.- Parameters:
region- The regionplayer- The playerreason- The reason
-
banPlayer
public static void banPlayer(long regionId, org.bukkit.OfflinePlayer player, @Nullable @Nullable String reason) Ban a player from accessing to a region.- Parameters:
regionId- The region IDplayer- The playerreason- The reason
-
unbanPlayer
Unban a player.- Parameters:
region- The regionplayer- The player
-
unbanPlayer
public static void unbanPlayer(long regionId, org.bukkit.OfflinePlayer player) Unban a player.- Parameters:
regionId- The region IDplayer- The player
-
unbanPlayer
Unban a player using raw UUIDs (useful when the player is completely offline and no OfflinePlayer exists).- Parameters:
regionId- The region IDplayerId- The player UUID
-
isBanned
Checks if a player is currently being banned by a region.- Parameters:
region- The regionplayer- The player- Returns:
trueif the player is banned,falseotherwise.
-
isBanned
public static boolean isBanned(long regionId, org.bukkit.OfflinePlayer player) Checks if a player is currently being banned by a region.- Parameters:
regionId- The region IDplayer- The player- Returns:
trueif the player is banned,falseotherwise.
-
isBanned
Checks if a player is banned from a region using UUIDs only.- Parameters:
regionId- The region IDplayerId- The player UUID- Returns:
trueif the player is banned,falseotherwise.
-
getBannedPlayer
Returns an instance ofRegionBanof a banned player from a region.- Parameters:
region- The regionplayer- The player- Returns:
RegionBanif the player is banned,nullotherwise.
-
getBannedPlayer
Returns an instance ofRegionBanof a banned player from a region.- Parameters:
regionId- The region IDplayer- The player- Returns:
RegionBanif the player is banned,nullotherwise.
-
getBannedPlayer
Returns an instance ofRegionBanof a banned player from a region using UUIDs only.- Parameters:
regionId- The region IDplayerId- The player UUID- Returns:
RegionBanif the player is banned,nullotherwise.
-
getBanReason
Returns the ban reason for a player in a region, ornullif not banned.- Parameters:
region- The regionplayer- The player- Returns:
- The ban reason, or
nullif not banned.
-
getBanReason
Returns the ban reason for a player in a region, ornullif not banned.- Parameters:
regionId- The region IDplayer- The player- Returns:
- The ban reason, or
nullif not banned.
-
getBanTime
Returns the timestamp when a player was banned from a region, or0if not banned.- Parameters:
region- The regionplayer- The player- Returns:
- The ban timestamp, or
0if not banned.
-
getBanTime
public static long getBanTime(long regionId, org.bukkit.OfflinePlayer player) Returns the timestamp when a player was banned from a region, or0if not banned.- Parameters:
regionId- The region IDplayer- The player- Returns:
- The ban timestamp, or
0if not banned.
-
updateBanReason
public static boolean updateBanReason(Region region, org.bukkit.OfflinePlayer player, @Nullable @Nullable String reason) Updates the ban reason for a player without recreating the ban entry.- Parameters:
region- The regionplayer- The playerreason- The new reason- Returns:
trueif the ban was found and updated,falseotherwise.
-
updateBanReason
public static boolean updateBanReason(long regionId, org.bukkit.OfflinePlayer player, @Nullable @Nullable String reason) Updates the ban reason for a player without recreating the ban entry.- Parameters:
regionId- The region IDplayer- The playerreason- The new reason- Returns:
trueif the ban was found and updated,falseotherwise.
-
getBansOfRegion
Returns a list of banned players from a region.- Parameters:
region- The region- Returns:
- List of banned players from a region.
-
getBansOfRegion
Returns a list of banned players from a region.- Parameters:
regionId- The region ID- Returns:
- List of banned players from a region.
-
getBanCount
public static int getBanCount()Returns the number of active bans in the server.- Returns:
- The ban count.
-
getBanCount
Returns the number of active bans in a region.- Parameters:
region- The region- Returns:
- The ban count.
-
getBanCount
public static int getBanCount(long regionId) Returns the number of active bans in a region.- Parameters:
regionId- The region ID- Returns:
- The ban count.
-
getBannedRegions
Returns all regions that a player is currently banned from.- Parameters:
player- The player- Returns:
- List of region IDs the player is banned from.
-
getBannedRegions
Returns all regions that a player is currently banned from.- Parameters:
playerId- The player UUID- Returns:
- List of region IDs the player is banned from.
-
getRecentBans
Returns the most recent bans for a region, sorted newest first.- Parameters:
region- The regionlimit- Maximum number of results- Returns:
- List of recent bans.
-
getRecentBans
Returns the most recent bans for a region, sorted newest first.- Parameters:
regionId- The region IDlimit- Maximum number of results- Returns:
- List of recent bans.
-
hasActiveBans
Checks if a region has any active bans.- Parameters:
region- The region- Returns:
trueif at least one ban exists.
-
hasActiveBans
public static boolean hasActiveBans(long regionId) Checks if a region has any active bans.- Parameters:
regionId- The region ID- Returns:
trueif at least one ban exists.
-
getAllBans
Returns an immutable view of every loaded ban entry.- Returns:
- List of all bans.
-
unbanAllPlayers
Unban all players from a region.- Parameters:
region- The region
-
unbanAllPlayers
public static void unbanAllPlayers(long regionId) Unban all players from a region.- Parameters:
regionId- The region ID
-
cleanupInvalidBans
public static int cleanupInvalidBans()Removes all ban entries with invalid references:
- Players whose UUID no longer maps to a known player
- Regions that no longer exist- Returns:
- Number of corrupted entries removed.
-