Class ModerationRepository

java.lang.Object
net.flectone.pulse.data.repository.ModerationRepository

public class ModerationRepository extends Object
Repository for managing moderation data in FlectonePulse. Provides caching and retrieval of player moderation's.
Since:
0.8.1
  • Constructor Details

  • Method Details

    • getValid

      public List<Moderation> getValid(@NonNull FPlayer player, Moderation.Type type, @Nullable String server, int limit, int offset)
      Retrieves valid (non-expired) moderations for a player with caching support. Checks cache consistency across servers and refreshes if server mismatch is detected. Only returns active moderations and updates cache accordingly.
      Parameters:
      player - the player to retrieve moderations for
      type - the moderation type to filter by
      server - the server ID (can be null for global search)
      limit - maximum number of results to return
      offset - number of results to skip for pagination
      Returns:
      list of valid moderation actions, or empty list if an error occurs
    • invalidate

      public void invalidate(@NonNull UUID playerId, Moderation.Type type, @Nullable String server)
      Invalidates cache for a specific player and moderation type.
      Parameters:
      playerId - the player UUID
      type - the moderation type
    • invalidateAll

      public void invalidateAll()
      Invalidates all moderation cache.
    • invalidateAll

      public void invalidateAll(@NonNull UUID playerId)
      Invalidates cache for all moderation types for a player.
      Parameters:
      playerId - the player UUID
    • save

      public Moderation save(@NonNull FPlayer fTarget, long date, long time, String reason, int moderatorID, Moderation.Type type, String server)
      Saves a new moderation.
      Parameters:
      fTarget - the target player
      date - the moderation date
      time - the expiration timestamp (-1 for permanent)
      reason - the moderation reason
      moderatorID - the moderator ID
      type - the moderation type
      server - the server ID
      Returns:
      the created moderation
    • getValid

      public List<Moderation> getValid(Moderation.Type type, @Nullable String server, int limit, int offset)
      Retrieves valid (non-expired) moderations by type across all players with pagination. This method does not use caching and queries the database directly.
      Parameters:
      type - the moderation type to filter by
      server - the server ID (can be null for global search)
      limit - maximum number of results to return
      offset - number of results to skip for pagination
      Returns:
      list of valid moderation actions matching the criteria
    • getValid

      public Optional<Moderation> getValid(@Nullable String server, int id)
      Retrieves a single valid moderation entry by its unique identifier. Checks that the moderation is valid and not expired.
      Parameters:
      server - the server ID (can be null for global search)
      id - the unique moderation entry identifier
      Returns:
      an Optional containing the moderation if found and valid, or empty otherwise
    • getValidNames

      public List<String> getValidNames(Moderation.Type type, @Nullable String server)
      Gets names of players with valid moderation's of a type.
      Parameters:
      type - the moderation type
      server - the server ID
      Returns:
      list of player names
    • getTotalValidCount

      public int getTotalValidCount(FPlayer fPlayer, Moderation.Type type, @Nullable String server)
      Counts the total number of valid moderations for a specific player and type. Only includes non-expired moderations.
      Parameters:
      fPlayer - the player to count moderations for
      type - the moderation type to filter by
      server - the server ID (can be null for global count)
      Returns:
      the count of valid moderations matching the criteria
    • getTotalValidCount

      public int getTotalValidCount(Moderation.Type type, @Nullable String server)
      Counts the total number of valid moderations by type across all players. Only includes non-expired moderations.
      Parameters:
      type - the moderation type to filter by
      server - the server ID (can be null for global count)
      Returns:
      the count of valid moderations matching the criteria
    • updateValid

      public void updateValid(int id, @Nullable String server)
      Invalidates a specific moderation entry by setting its valid flag to false. This effectively removes it from active moderation lists without deleting the record.
      Parameters:
      id - the unique moderation entry identifier to invalidate
      server - the server ID (can be null for global invalidation)
    • updateValid

      public void updateValid(int playerId, @NonNull Moderation.Type type, @Nullable String server)
      Invalidates all player moderation entries of a specific type by setting their valid flag to false. Can be filtered by server to target server-specific moderations only.
      Parameters:
      playerId - the player ID
      type - the moderation type to invalidate
      server - the server ID (can be null for global invalidation)