Class ModerationDAO

java.lang.Object
net.flectone.pulse.data.database.dao.ModerationDAO
All Implemented Interfaces:
BaseDAO<ModerationSQL>

public class ModerationDAO extends Object implements BaseDAO<ModerationSQL>
Data Access Object for moderation data in FlectonePulse. Handles player moderation actions like kicks, bans, mutes, and warnings.
Since:
0.9.0
  • Constructor Details

    • ModerationDAO

      @Inject public ModerationDAO(Database database)
  • Method Details

    • database

      public Database database()
      Description copied from interface: BaseDAO
      Gets the database instance associated with this DAO.
      Specified by:
      database in interface BaseDAO<ModerationSQL>
      Returns:
      the database instance
    • sqlClass

      public Class<? extends ModerationSQL> sqlClass()
      Description copied from interface: BaseDAO
      Gets the SQL interface class for this DAO.
      Specified by:
      sqlClass in interface BaseDAO<ModerationSQL>
      Returns:
      the SQL interface class
    • getValid

      public List<Moderation> getValid(@NonNull FPlayer player, Moderation.Type type, @Nullable String server, int limit, int offset)
      Retrieves valid (non-expired) moderation actions for a specific player and type with pagination. Returns an empty list if the player is unknown.
      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 matching the criteria
    • getValid

      public List<Moderation> getValid(Moderation.Type type, @Nullable String server, int limit, int offset)
      Retrieves valid (non-expired) moderation actions by type across all players with pagination.
      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
    • getValidById

      public Optional<Moderation> getValidById(@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
    • getValidPlayersNames

      public List<String> getValidPlayersNames(Moderation.Type type, @Nullable String server)
      Gets names of players with valid moderation actions 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
    • insert

      public @Nullable Moderation insert(@NonNull FPlayer target, long date, long time, String reason, int moderatorId, Moderation.Type type, String server)
      Inserts a new moderation action.
      Parameters:
      target - 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 action, or null if player is unknown
    • 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)