Class PunishmentUserProvider
java.lang.Object
de.murmelmeister.murmelapi.punishment.PunishmentUserProvider
- All Implemented Interfaces:
PunishmentUser
-
Constructor Summary
ConstructorsConstructorDescriptionPunishmentUserProvider(Database database, PunishmentReason reason, PunishmentLog log) -
Method Summary
Modifier and TypeMethodDescriptionbooleanexists(int userId, int typeId) Checks if a record or punishment exists for a specific type and user.getCreatedAt(int userId, int typeId) Retrieves the timestamp representing when the entity associated with the specified type and user was created.intgetCreatedBy(int userId, int typeId) Retrieves the identifier of the user who created a punishment record.longgetDuration(int userId, int typeId) Retrieves the duration of a punishment for a specified type and user.getExpiredDate(int userId, int typeId) Retrieves the expiration date of a punishment for a specific user and type.longgetExpiredTime(int userId, int typeId) Retrieves the expiration time of a punishment for a specific user and type.getLogId(int userId, int typeId) Retrieves the log identifier related to a specific type and user.getModifiedAt(int userId, int typeId) Retrieves the timestamp of the last modification made to the punishment details of a user specified by their type ID and user ID.intgetModifiedBy(int userId, int typeId) Retrieves the ID of the user who last modified the punishment record.getReason(int userId, int typeId) Retrieves the reason associated with a specified type and user by their respective IDs.intgetReasonId(int userId, int typeId) Retrieves the reason ID associated with the specified type and user ID.getUsers(int typeId) Retrieves a list of user IDs associated with the specified punishment type.booleanisPunished(int userId, int typeId) Determines whether the specified user is currently punished for the given type.voidpunish(int userId, int typeId, int executorId, InetAddress inetAddress, int reasonId) Applies a punishment to a user.voidsetExpiredTime(int userId, int typeId, int executorId, long time) Sets the expiration time for a punishment record.voidsetReasonId(int userId, int typeId, int executorId, int reasonId) Updates the reason associated with the punishment of a user.static voidvoidunpunished(int userId, int typeId) Removes the punishment for the specified user and type.
-
Constructor Details
-
PunishmentUserProvider
-
-
Method Details
-
setup
-
exists
public boolean exists(int userId, int typeId) Description copied from interface:PunishmentUserChecks if a record or punishment exists for a specific type and user.- Specified by:
existsin interfacePunishmentUser- Parameters:
userId- The ID of the user to check for the existence of the record.typeId- The ID of the punishment type to check.- Returns:
- true if the record exists, false otherwise.
-
punish
Description copied from interface:PunishmentUserApplies a punishment to a user.- Specified by:
punishin interfacePunishmentUser- Parameters:
userId- The ID of the user being punishedtypeId- The ID representing the type of punishmentexecutorId- The ID of the executor performing the punishmentinetAddress- The network address associated with the userreasonId- The ID representing the reason for the punishment
-
unpunished
public void unpunished(int userId, int typeId) Description copied from interface:PunishmentUserRemoves the punishment for the specified user and type.- Specified by:
unpunishedin interfacePunishmentUser- Parameters:
userId- The identifier of the usertypeId- The identifier of the punishment type
-
getUsers
Description copied from interface:PunishmentUserRetrieves a list of user IDs associated with the specified punishment type.- Specified by:
getUsersin interfacePunishmentUser- Parameters:
typeId- The ID of the punishment type- Returns:
- A list of user IDs associated with the specified punishment type
-
getLogId
Description copied from interface:PunishmentUserRetrieves the log identifier related to a specific type and user.- Specified by:
getLogIdin interfacePunishmentUser- Parameters:
userId- The unique identifier of the user.typeId- The type identifier associated with the user.- Returns:
- The UUID representing the log identifier for the given type and user.
-
getReasonId
public int getReasonId(int userId, int typeId) Description copied from interface:PunishmentUserRetrieves the reason ID associated with the specified type and user ID.- Specified by:
getReasonIdin interfacePunishmentUser- Parameters:
userId- The ID of the user for whom the reason ID is requested.typeId- The ID representing the type of punishment.- Returns:
- The reason ID associated with the given type and user ID.
-
setReasonId
public void setReasonId(int userId, int typeId, int executorId, int reasonId) Description copied from interface:PunishmentUserUpdates the reason associated with the punishment of a user.- Specified by:
setReasonIdin interfacePunishmentUser- Parameters:
userId- The identifier of the user being punished.typeId- The type identifier of the punishment.executorId- The identifier of the executor making the change.reasonId- The identifier of the new reason for the punishment.
-
getReason
Description copied from interface:PunishmentUserRetrieves the reason associated with a specified type and user by their respective IDs.- Specified by:
getReasonin interfacePunishmentUser- Parameters:
userId- The ID representing the user associated with the punishment or actiontypeId- The ID representing the type of the punishment or action- Returns:
- The reason as a string for the specified type and user
-
getDuration
public long getDuration(int userId, int typeId) Description copied from interface:PunishmentUserRetrieves the duration of a punishment for a specified type and user.- Specified by:
getDurationin interfacePunishmentUser- Parameters:
userId- The ID of the user whose punishment duration is to be retrieved.typeId- The ID representing the type of punishment.- Returns:
- The duration of the punishment in milliseconds.
-
getExpiredTime
public long getExpiredTime(int userId, int typeId) Description copied from interface:PunishmentUserRetrieves the expiration time of a punishment for a specific user and type.- Specified by:
getExpiredTimein interfacePunishmentUser- Parameters:
userId- The ID of the user associated with the punishment.typeId- The ID of the punishment type.- Returns:
- The expiration time of the punishment as a timestamp in milliseconds.
-
getExpiredDate
Description copied from interface:PunishmentUserRetrieves the expiration date of a punishment for a specific user and type.- Specified by:
getExpiredDatein interfacePunishmentUser- Parameters:
userId- The unique identifier of the usertypeId- The unique identifier of the punishment type- Returns:
- A string representing the expiration date of the punishment, or null if no expiration date is set
-
setExpiredTime
public void setExpiredTime(int userId, int typeId, int executorId, long time) Description copied from interface:PunishmentUserSets the expiration time for a punishment record.- Specified by:
setExpiredTimein interfacePunishmentUser- Parameters:
userId- The identifier of the user being punishedtypeId- The type of punishment being setexecutorId- The identifier of the executor making the changetime- The expiration time of the punishment, in milliseconds since epoch
-
isPunished
public boolean isPunished(int userId, int typeId) Description copied from interface:PunishmentUserDetermines whether the specified user is currently punished for the given type.- Specified by:
isPunishedin interfacePunishmentUser- Parameters:
userId- The identifier of the usertypeId- The identifier of the punishment type- Returns:
- true if the user is currently punished for the specified type, false otherwise
-
getCreatedBy
public int getCreatedBy(int userId, int typeId) Description copied from interface:PunishmentUserRetrieves the identifier of the user who created a punishment record.- Specified by:
getCreatedByin interfacePunishmentUser- Parameters:
userId- The ID of the affected user.typeId- The ID of the punishment type.- Returns:
- The ID of the user who created the punishment.
-
getCreatedAt
Description copied from interface:PunishmentUserRetrieves the timestamp representing when the entity associated with the specified type and user was created.- Specified by:
getCreatedAtin interfacePunishmentUser- Parameters:
userId- The ID of the user associated with the creationtypeId- The ID of the type associated with the creation- Returns:
- The creation timestamp of the associated type and user
-
getModifiedBy
public int getModifiedBy(int userId, int typeId) Description copied from interface:PunishmentUserRetrieves the ID of the user who last modified the punishment record.- Specified by:
getModifiedByin interfacePunishmentUser- Parameters:
userId- The user identifier related to the punishment recordtypeId- The type identifier associated with the punishment record- Returns:
- The ID of the user who last modified the punishment record
-
getModifiedAt
Description copied from interface:PunishmentUserRetrieves the timestamp of the last modification made to the punishment details of a user specified by their type ID and user ID.- Specified by:
getModifiedAtin interfacePunishmentUser- Parameters:
userId- The unique identifier for the usertypeId- The unique identifier for the punishment type- Returns:
- A
Timestamprepresenting the last modification time for the specified type and user
-