java.lang.Object
tfagaming.projects.minecraft.homestead.managers.BanManager

public final class BanManager extends Object
A utility class that manages RegionBan.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    banPlayer(long regionId, org.bukkit.OfflinePlayer player, @Nullable String reason)
    Ban a player from accessing to a region.
    static void
    banPlayer(Region region, org.bukkit.OfflinePlayer player, @Nullable String reason)
    Ban a player from accessing to a region.
    static int
    Removes all ban entries with invalid references:
    - Players whose UUID no longer maps to a known player
    - Regions that no longer exist
    static List<RegionBan>
    Returns an immutable view of every loaded ban entry.
    static int
    Returns the number of active bans in the server.
    static int
    getBanCount(long regionId)
    Returns the number of active bans in a region.
    static int
    Returns the number of active bans in a region.
    static RegionBan
    getBannedPlayer(long regionId, UUID playerId)
    Returns an instance of RegionBan of a banned player from a region using UUIDs only.
    static RegionBan
    getBannedPlayer(long regionId, org.bukkit.OfflinePlayer player)
    Returns an instance of RegionBan of a banned player from a region.
    static RegionBan
    getBannedPlayer(Region region, org.bukkit.OfflinePlayer player)
    Returns an instance of RegionBan of a banned player from a region.
    static List<Long>
    Returns all regions that a player is currently banned from.
    static List<Long>
    getBannedRegions(org.bukkit.OfflinePlayer player)
    Returns all regions that a player is currently banned from.
    static String
    getBanReason(long regionId, org.bukkit.OfflinePlayer player)
    Returns the ban reason for a player in a region, or null if not banned.
    static String
    getBanReason(Region region, org.bukkit.OfflinePlayer player)
    Returns the ban reason for a player in a region, or null if not banned.
    static List<RegionBan>
    getBansOfRegion(long regionId)
    Returns a list of banned players from a region.
    static List<RegionBan>
    Returns a list of banned players from a region.
    static long
    getBanTime(long regionId, org.bukkit.OfflinePlayer player)
    Returns the timestamp when a player was banned from a region, or 0 if not banned.
    static long
    getBanTime(Region region, org.bukkit.OfflinePlayer player)
    Returns the timestamp when a player was banned from a region, or 0 if not banned.
    static List<RegionBan>
    getRecentBans(long regionId, int limit)
    Returns the most recent bans for a region, sorted newest first.
    static List<RegionBan>
    getRecentBans(Region region, int limit)
    Returns the most recent bans for a region, sorted newest first.
    static boolean
    hasActiveBans(long regionId)
    Checks if a region has any active bans.
    static boolean
    Checks if a region has any active bans.
    static boolean
    isBanned(long regionId, UUID playerId)
    Checks if a player is banned from a region using UUIDs only.
    static boolean
    isBanned(long regionId, org.bukkit.OfflinePlayer player)
    Checks if a player is currently being banned by a region.
    static boolean
    isBanned(Region region, org.bukkit.OfflinePlayer player)
    Checks if a player is currently being banned by a region.
    static void
    unbanAllPlayers(long regionId)
    Unban all players from a region.
    static void
    Unban all players from a region.
    static void
    unbanPlayer(long regionId, UUID playerId)
    Unban a player using raw UUIDs (useful when the player is completely offline and no OfflinePlayer exists).
    static void
    unbanPlayer(long regionId, org.bukkit.OfflinePlayer player)
    Unban a player.
    static void
    unbanPlayer(Region region, org.bukkit.OfflinePlayer player)
    Unban a player.
    static boolean
    updateBanReason(long regionId, org.bukkit.OfflinePlayer player, @Nullable String reason)
    Updates the ban reason for a player without recreating the ban entry.
    static boolean
    updateBanReason(Region region, org.bukkit.OfflinePlayer player, @Nullable String reason)
    Updates the ban reason for a player without recreating the ban entry.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 region
      player - The player
      reason - 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 ID
      player - The player
      reason - The reason
    • unbanPlayer

      public static void unbanPlayer(Region region, org.bukkit.OfflinePlayer player)
      Unban a player.
      Parameters:
      region - The region
      player - The player
    • unbanPlayer

      public static void unbanPlayer(long regionId, org.bukkit.OfflinePlayer player)
      Unban a player.
      Parameters:
      regionId - The region ID
      player - The player
    • unbanPlayer

      public static void unbanPlayer(long regionId, UUID playerId)
      Unban a player using raw UUIDs (useful when the player is completely offline and no OfflinePlayer exists).
      Parameters:
      regionId - The region ID
      playerId - The player UUID
    • isBanned

      public static boolean isBanned(Region region, org.bukkit.OfflinePlayer player)
      Checks if a player is currently being banned by a region.
      Parameters:
      region - The region
      player - The player
      Returns:
      true if the player is banned, false otherwise.
    • 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 ID
      player - The player
      Returns:
      true if the player is banned, false otherwise.
    • isBanned

      public static boolean isBanned(long regionId, UUID playerId)
      Checks if a player is banned from a region using UUIDs only.
      Parameters:
      regionId - The region ID
      playerId - The player UUID
      Returns:
      true if the player is banned, false otherwise.
    • getBannedPlayer

      public static RegionBan getBannedPlayer(Region region, org.bukkit.OfflinePlayer player)
      Returns an instance of RegionBan of a banned player from a region.
      Parameters:
      region - The region
      player - The player
      Returns:
      RegionBan if the player is banned, null otherwise.
    • getBannedPlayer

      public static RegionBan getBannedPlayer(long regionId, org.bukkit.OfflinePlayer player)
      Returns an instance of RegionBan of a banned player from a region.
      Parameters:
      regionId - The region ID
      player - The player
      Returns:
      RegionBan if the player is banned, null otherwise.
    • getBannedPlayer

      public static RegionBan getBannedPlayer(long regionId, UUID playerId)
      Returns an instance of RegionBan of a banned player from a region using UUIDs only.
      Parameters:
      regionId - The region ID
      playerId - The player UUID
      Returns:
      RegionBan if the player is banned, null otherwise.
    • getBanReason

      public static String getBanReason(Region region, org.bukkit.OfflinePlayer player)
      Returns the ban reason for a player in a region, or null if not banned.
      Parameters:
      region - The region
      player - The player
      Returns:
      The ban reason, or null if not banned.
    • getBanReason

      public static String getBanReason(long regionId, org.bukkit.OfflinePlayer player)
      Returns the ban reason for a player in a region, or null if not banned.
      Parameters:
      regionId - The region ID
      player - The player
      Returns:
      The ban reason, or null if not banned.
    • getBanTime

      public static long getBanTime(Region region, org.bukkit.OfflinePlayer player)
      Returns the timestamp when a player was banned from a region, or 0 if not banned.
      Parameters:
      region - The region
      player - The player
      Returns:
      The ban timestamp, or 0 if not banned.
    • getBanTime

      public static long getBanTime(long regionId, org.bukkit.OfflinePlayer player)
      Returns the timestamp when a player was banned from a region, or 0 if not banned.
      Parameters:
      regionId - The region ID
      player - The player
      Returns:
      The ban timestamp, or 0 if 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 region
      player - The player
      reason - The new reason
      Returns:
      true if the ban was found and updated, false otherwise.
    • 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 ID
      player - The player
      reason - The new reason
      Returns:
      true if the ban was found and updated, false otherwise.
    • getBansOfRegion

      public static List<RegionBan> getBansOfRegion(Region region)
      Returns a list of banned players from a region.
      Parameters:
      region - The region
      Returns:
      List of banned players from a region.
    • getBansOfRegion

      public static List<RegionBan> getBansOfRegion(long regionId)
      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

      public static int getBanCount(Region region)
      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

      public static List<Long> getBannedRegions(org.bukkit.OfflinePlayer player)
      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

      public static List<Long> getBannedRegions(UUID playerId)
      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

      public static List<RegionBan> getRecentBans(Region region, int limit)
      Returns the most recent bans for a region, sorted newest first.
      Parameters:
      region - The region
      limit - Maximum number of results
      Returns:
      List of recent bans.
    • getRecentBans

      public static List<RegionBan> getRecentBans(long regionId, int limit)
      Returns the most recent bans for a region, sorted newest first.
      Parameters:
      regionId - The region ID
      limit - Maximum number of results
      Returns:
      List of recent bans.
    • hasActiveBans

      public static boolean hasActiveBans(Region region)
      Checks if a region has any active bans.
      Parameters:
      region - The region
      Returns:
      true if 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:
      true if at least one ban exists.
    • getAllBans

      public static List<RegionBan> getAllBans()
      Returns an immutable view of every loaded ban entry.
      Returns:
      List of all bans.
    • unbanAllPlayers

      public static void unbanAllPlayers(Region region)
      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.