Interface ModerationService
public interface ModerationService
Issues, revokes and looks up punishments, and tracks the violation counters that decide
when a chat rule turns into an automatic punishment.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordIdentifies a violation counter by one player against one module. -
Method Summary
Modifier and TypeMethodDescription@Nullable Moderationadd(FPlayer fPlayer, long date, long time, String reason, int moderator, Moderation.Type type, @Nullable String server) Stores a punishment with an explicit issue date and server, used when replaying one that arrived from another server.@Nullable Moderationadd(FPlayer fPlayer, long time, String reason, int moderator, Moderation.Type type) Stores a punishment of any type, issued as of now.voidaddViolation(UUID uuid, ModuleSimple moduleSimple, ViolationSetting violationSetting) Records that a player broke a chat rule, which may trip the module's violation limit.voidaddViolation(ModerationService.ViolationKey violationKey, Long violationValue) Records a violation directly, used when the count arrives from another server.@Nullable ModerationBans a player.getAll(FPlayer fPlayer, Moderation.Type type, @Nullable String server, int limit, int offset) Retrieves all moderation records for a player, including expired and invalidated ones.getFirstViolationTimestamp(UUID uuid, ModuleSimple moduleSimple) When the current run of violations started, which is where the limit window is measured from.getServer(Moderation.Type type) The server name punishments of this type are recorded against, either this server or a shared name when the punishment is network-wide.intgetTotalCount(FPlayer fPlayer, Moderation.Type type, @Nullable String server) Counts the total number of moderation records for a player, regardless of validity status.intgetTotalValidCount(FPlayer fPlayer, Moderation.Type type, @Nullable String server) How many active punishments of a type a player has, used to size the list pages.intgetTotalValidCount(Moderation.Type type, @Nullable String server) How many active punishments of a type exist in total.getValid(FPlayer fPlayer, Moderation.Type type) The active punishment of a type for a player.getValid(FPlayer fPlayer, Moderation.Type type, int limit, int offset) A page of a player's active punishments, for the list commands.getValid(FPlayer fPlayer, Moderation.Type type, String server, int limit, int offset) A page of a player's active punishments on one server, for the list commands.getValid(Moderation.Type type, int id) One active punishment by id.getValid(Moderation.Type type, int limit, int offset) A page of every active punishment of a type, across all players.getValidNames(Moderation.Type type) The names of everyone with an active punishment of a type, used for command suggestions.booleanhasHigherGroupThan(FPlayer source, FPlayer target) Whether one player outranks another, which decides if they may punish them.booleanhasValid(FPlayer fTarget, Moderation.Type type) Whether a player has an active punishment of the given type.booleanhasValid(FPlayer fTarget, Moderation.Type type, int id) Whether one specific punishment is still in force.voidDrops every cached punishment.voidinvalidate(UUID uuid) Drops the cached punishments of one player.voidinvalidate(UUID uuid, Moderation.Type type) Drops the cached punishments of one player for one punishment type.voidinvalidate(FPlayer fTarget, Moderation.Type type, int id) Drops one cached punishment and tells the other servers to do the same.voidinvalidate(FPlayer fTarget, Moderation.Type type, int id, @Nullable String server) Drops one cached punishment, optionally scoped to a single server.booleanisAllowedTime(FPlayer fPlayer, long time, Map<Integer, Long> timeLimits) Whether a moderator may issue a punishment of this length, given the per-group limits.booleanisViolationRestricted(UUID uuid, ModuleSimple moduleSimple, ViolationSetting violationSetting) Whether a player has broken a rule often enough to be punished for it.@Nullable ModerationKicks a player.@Nullable Moderationmaintenance(FPlayer fPlayer, long time, String reason, int moderator) Puts the server into maintenance, which keeps everyone but the allowed players out.@Nullable ModerationMutes a player.@Nullable Moderationremove(FPlayer fModerator, FPlayer fTarget, Moderation.Type type, int id, @Nullable String reason) Revokes a punishment.@Nullable Moderationremove(FPlayer fModerator, FPlayer fTarget, Moderation.Type type, int id, @Nullable String reason, @Nullable String server) Revokes a punishment on one server.@Nullable Moderationremove(FPlayer fModerator, FPlayer fTarget, Moderation.Type type, long time, int id, @Nullable String reason) Revokes a punishment as of a given moment, so the record keeps the real end time.@Nullable Moderationremove(FPlayer fModerator, FPlayer fTarget, Moderation.Type type, long time, int id, @Nullable String reason, @Nullable String server) Revokes a punishment as of a given moment on one server.@Nullable ModerationWarns a player.@Nullable ModerationAdds a player to the whitelist.
-
Method Details
-
invalidate
void invalidate()Drops every cached punishment. -
invalidate
Drops the cached punishments of one player.- Parameters:
uuid- the player id
-
invalidate
Drops one cached punishment and tells the other servers to do the same.- Parameters:
fTarget- the punished playertype- the punishment typeid- the punishment id
-
invalidate
Drops one cached punishment, optionally scoped to a single server.- Parameters:
fTarget- the punished playertype- the punishment typeid- the punishment idserver- the server it applies to, or null for every server
-
invalidate
Drops the cached punishments of one player for one punishment type.- Parameters:
uuid- the player idtype- the punishment type
-
ban
Bans a player.- Parameters:
fPlayer- the player to bantime- when the ban expires in milliseconds, orModeration.PERMANENT_TIMEreason- the stated reasonmoderator- the issuing player id- Returns:
- the stored punishment, or null if it could not be saved
-
mute
Mutes a player.- Parameters:
fPlayer- the player to mutetime- when the mute expires in milliseconds, orModeration.PERMANENT_TIMEreason- the stated reasonmoderator- the issuing player id- Returns:
- the stored punishment, or null if it could not be saved
-
maintenance
Puts the server into maintenance, which keeps everyone but the allowed players out.- Parameters:
fPlayer- the player the entry is recorded againsttime- when maintenance ends in milliseconds, orModeration.PERMANENT_TIMEreason- the stated reasonmoderator- the issuing player id- Returns:
- the stored entry, or null if it could not be saved
-
warn
Warns a player.- Parameters:
fPlayer- the player to warntime- when the warning expires in milliseconds, orModeration.PERMANENT_TIMEreason- the stated reasonmoderator- the issuing player id- Returns:
- the stored punishment, or null if it could not be saved
-
kick
Kicks a player. A kick has no duration, so it is only recorded for the history.- Parameters:
fPlayer- the player to kickreason- the stated reasonmoderator- the issuing player id- Returns:
- the stored entry, or null if it could not be saved
-
whitelist
Adds a player to the whitelist.- Parameters:
fPlayer- the player to allow intime- when the entry expires in milliseconds, orModeration.PERMANENT_TIMEreason- the stated reasonmoderator- the issuing player id- Returns:
- the stored entry, or null if it could not be saved
-
hasValid
Whether a player has an active punishment of the given type.- Parameters:
fTarget- the player to checktype- the punishment type- Returns:
- true if one is in force
-
hasValid
Whether one specific punishment is still in force.- Parameters:
fTarget- the player to checktype- the punishment typeid- the punishment id- Returns:
- true if it is in force
-
getAll
List<Moderation> getAll(FPlayer fPlayer, Moderation.Type type, @Nullable String server, int limit, int offset) Retrieves all moderation records for a player, including expired and invalidated ones.- Parameters:
fPlayer- 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 all moderation records matching the criteria
-
getValid
The active punishment of a type for a player.- Parameters:
fPlayer- the player to checktype- the punishment type- Returns:
- the punishment, or empty if there is none
-
getValid
List<Moderation> getValid(FPlayer fPlayer, Moderation.Type type, String server, int limit, int offset) A page of a player's active punishments on one server, for the list commands.- Parameters:
fPlayer- the player to checktype- the punishment typeserver- the server to list from, or null for every serverlimit- how many to returnoffset- how many to skip- Returns:
- the page
-
getValid
A page of a player's active punishments, for the list commands.- Parameters:
fPlayer- the player to checktype- the punishment typelimit- how many to returnoffset- how many to skip- Returns:
- the page
-
getValid
A page of every active punishment of a type, across all players.- Parameters:
type- the punishment typelimit- how many to returnoffset- how many to skip- Returns:
- the page
-
getValid
One active punishment by id.- Parameters:
type- the punishment typeid- the punishment id- Returns:
- the punishment, or empty if it is not active
-
getValidNames
The names of everyone with an active punishment of a type, used for command suggestions.- Parameters:
type- the punishment type- Returns:
- the player names
-
getTotalCount
Counts the total number of moderation records for a player, regardless of validity status.- 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 total count of moderation records matching the criteria
-
getTotalValidCount
How many active punishments of a type a player has, used to size the list pages.- Parameters:
fPlayer- the player to checktype- the punishment typeserver- the server to count on, or null for every server- Returns:
- the count
-
getTotalValidCount
How many active punishments of a type exist in total.- Parameters:
type- the punishment typeserver- the server to count on, or null for every server- Returns:
- the count
-
add
@Nullable Moderation add(FPlayer fPlayer, long time, String reason, int moderator, Moderation.Type type) Stores a punishment of any type, issued as of now.- Parameters:
fPlayer- the punished playertime- when it expires in milliseconds, orModeration.PERMANENT_TIMEreason- the stated reasonmoderator- the issuing player idtype- the punishment type- Returns:
- the stored punishment, or null if it could not be saved
-
add
@Nullable Moderation add(FPlayer fPlayer, long date, long time, String reason, int moderator, Moderation.Type type, @Nullable String server) Stores a punishment with an explicit issue date and server, used when replaying one that arrived from another server.- Parameters:
fPlayer- the punished playerdate- when it was issued, in millisecondstime- when it expires in milliseconds, orModeration.PERMANENT_TIMEreason- the stated reasonmoderator- the issuing player idtype- the punishment typeserver- the server it applies to, or null for every server- Returns:
- the stored punishment, or null if it could not be saved
-
addViolation
Records that a player broke a chat rule, which may trip the module's violation limit.- Parameters:
uuid- the player idmoduleSimple- the module whose rule was brokenviolationSetting- the limit settings
-
addViolation
Records a violation directly, used when the count arrives from another server.- Parameters:
violationKey- the player and module the count belongs toviolationValue- when the violation happened, in milliseconds
-
isViolationRestricted
boolean isViolationRestricted(UUID uuid, ModuleSimple moduleSimple, ViolationSetting violationSetting) Whether a player has broken a rule often enough to be punished for it.- Parameters:
uuid- the player idmoduleSimple- the module whose rule was brokenviolationSetting- the limit settings- Returns:
- true if the limit has been reached
-
getFirstViolationTimestamp
When the current run of violations started, which is where the limit window is measured from.- Parameters:
uuid- the player idmoduleSimple- the module whose rule was broken- Returns:
- the timestamp in milliseconds, or null if there are no violations on record
-
remove
@Nullable Moderation remove(FPlayer fModerator, FPlayer fTarget, Moderation.Type type, int id, @Nullable String reason) Revokes a punishment.- Parameters:
fModerator- who is revoking itfTarget- the punished playertype- the punishment typeid- the punishment id, or -1 for the most recent onereason- the stated reason, may be null- Returns:
- the revoked punishment, or null if there was nothing to revoke
-
remove
@Nullable Moderation remove(FPlayer fModerator, FPlayer fTarget, Moderation.Type type, int id, @Nullable String reason, @Nullable String server) Revokes a punishment on one server.- Parameters:
fModerator- who is revoking itfTarget- the punished playertype- the punishment typeid- the punishment id, or -1 for the most recent onereason- the stated reason, may be nullserver- the server to revoke it on, or null for every server- Returns:
- the revoked punishment, or null if there was nothing to revoke
-
remove
@Nullable Moderation remove(FPlayer fModerator, FPlayer fTarget, Moderation.Type type, long time, int id, @Nullable String reason) Revokes a punishment as of a given moment, so the record keeps the real end time.- Parameters:
fModerator- who is revoking itfTarget- the punished playertype- the punishment typetime- when it stopped applying, in millisecondsid- the punishment id, or -1 for the most recent onereason- the stated reason, may be null- Returns:
- the revoked punishment, or null if there was nothing to revoke
-
remove
@Nullable Moderation remove(FPlayer fModerator, FPlayer fTarget, Moderation.Type type, long time, int id, @Nullable String reason, @Nullable String server) Revokes a punishment as of a given moment on one server.- Parameters:
fModerator- who is revoking itfTarget- the punished playertype- the punishment typetime- when it stopped applying, in millisecondsid- the punishment id, or -1 for the most recent onereason- the stated reason, may be nullserver- the server to revoke it on, or null for every server- Returns:
- the revoked punishment, or null if there was nothing to revoke
-
isAllowedTime
Whether a moderator may issue a punishment of this length, given the per-group limits.- Parameters:
fPlayer- the issuing moderatortime- the requested duration in millisecondstimeLimits- the longest duration each group may issue- Returns:
- true if the duration is allowed
-
hasHigherGroupThan
-
getServer
The server name punishments of this type are recorded against, either this server or a shared name when the punishment is network-wide.- Parameters:
type- the punishment type- Returns:
- the server name
-