Class ModerationDAO
java.lang.Object
net.flectone.pulse.data.database.dao.ModerationDAO
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondatabase()Gets the database instance associated with this DAO.intgetTotalValidCount(FPlayer fPlayer, Moderation.Type type, @Nullable String server) Counts the total number of valid moderations for a specific player and type.intgetTotalValidCount(Moderation.Type type, @Nullable String server) Counts the total number of valid moderations by type across all players.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.getValid(Moderation.Type type, @Nullable String server, int limit, int offset) Retrieves valid (non-expired) moderation actions by type across all players with pagination.getValidById(@Nullable String server, int id) Retrieves a single valid moderation entry by its unique identifier.getValidPlayersNames(Moderation.Type type, @Nullable String server) Gets names of players with valid moderation actions of a type.@Nullable Moderationinsert(@NonNull FPlayer target, long date, long time, String reason, int moderatorId, Moderation.Type type, String server) Inserts a new moderation action.Class<? extends ModerationSQL> sqlClass()Gets the SQL interface class for this DAO.voidupdateValid(int id, @Nullable String server) Invalidates a specific moderation entry by setting its valid flag to false.voidupdateValid(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.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface BaseDAO
getSQL, inTransaction, useCustomTransaction, useHandle, useTransaction, withHandle
-
Constructor Details
-
ModerationDAO
-
-
Method Details
-
database
Description copied from interface:BaseDAOGets the database instance associated with this DAO.- Specified by:
databasein interfaceBaseDAO<ModerationSQL>- Returns:
- the database instance
-
sqlClass
Description copied from interface:BaseDAOGets the SQL interface class for this DAO.- Specified by:
sqlClassin interfaceBaseDAO<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 fortype- the moderation type to filter byserver- the server ID (can be null for global search)limit- maximum number of results to returnoffset- 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 byserver- the server ID (can be null for global search)limit- maximum number of results to returnoffset- number of results to skip for pagination- Returns:
- list of valid moderation actions matching the criteria
-
getValidById
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
Gets names of players with valid moderation actions of a type.- Parameters:
type- the moderation typeserver- the server ID- Returns:
- list of player names
-
getTotalValidCount
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 fortype- the moderation type to filter byserver- the server ID (can be null for global count)- Returns:
- the count of valid moderations matching the criteria
-
getTotalValidCount
Counts the total number of valid moderations by type across all players. Only includes non-expired moderations.- Parameters:
type- the moderation type to filter byserver- 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 playerdate- the moderation datetime- the expiration timestamp (-1 for permanent)reason- the moderation reasonmoderatorId- the moderator IDtype- the moderation typeserver- the server ID- Returns:
- the created moderation action, or null if player is unknown
-
updateValid
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 invalidateserver- the server ID (can be null for global invalidation)
-
updateValid
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 IDtype- the moderation type to invalidateserver- the server ID (can be null for global invalidation)
-