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.
  • Method Details

    • invalidate

      void invalidate()
      Drops every cached punishment.
    • invalidate

      void invalidate(UUID uuid)
      Drops the cached punishments of one player.
      Parameters:
      uuid - the player id
    • invalidate

      void invalidate(FPlayer fTarget, Moderation.Type type, int id)
      Drops one cached punishment and tells the other servers to do the same.
      Parameters:
      fTarget - the punished player
      type - the punishment type
      id - the punishment id
    • invalidate

      void invalidate(FPlayer fTarget, Moderation.Type type, int id, @Nullable String server)
      Drops one cached punishment, optionally scoped to a single server.
      Parameters:
      fTarget - the punished player
      type - the punishment type
      id - the punishment id
      server - the server it applies to, or null for every server
    • invalidate

      void invalidate(UUID uuid, Moderation.Type type)
      Drops the cached punishments of one player for one punishment type.
      Parameters:
      uuid - the player id
      type - the punishment type
    • ban

      @Nullable Moderation ban(FPlayer fPlayer, long time, String reason, int moderator)
      Bans a player.
      Parameters:
      fPlayer - the player to ban
      time - when the ban expires in milliseconds, or Moderation.PERMANENT_TIME
      reason - the stated reason
      moderator - the issuing player id
      Returns:
      the stored punishment, or null if it could not be saved
    • mute

      @Nullable Moderation mute(FPlayer fPlayer, long time, String reason, int moderator)
      Mutes a player.
      Parameters:
      fPlayer - the player to mute
      time - when the mute expires in milliseconds, or Moderation.PERMANENT_TIME
      reason - the stated reason
      moderator - the issuing player id
      Returns:
      the stored punishment, or null if it could not be saved
    • maintenance

      @Nullable Moderation maintenance(FPlayer fPlayer, long time, String reason, int moderator)
      Puts the server into maintenance, which keeps everyone but the allowed players out.
      Parameters:
      fPlayer - the player the entry is recorded against
      time - when maintenance ends in milliseconds, or Moderation.PERMANENT_TIME
      reason - the stated reason
      moderator - the issuing player id
      Returns:
      the stored entry, or null if it could not be saved
    • warn

      @Nullable Moderation warn(FPlayer fPlayer, long time, String reason, int moderator)
      Warns a player.
      Parameters:
      fPlayer - the player to warn
      time - when the warning expires in milliseconds, or Moderation.PERMANENT_TIME
      reason - the stated reason
      moderator - the issuing player id
      Returns:
      the stored punishment, or null if it could not be saved
    • kick

      @Nullable Moderation kick(FPlayer fPlayer, String reason, int moderator)
      Kicks a player. A kick has no duration, so it is only recorded for the history.
      Parameters:
      fPlayer - the player to kick
      reason - the stated reason
      moderator - the issuing player id
      Returns:
      the stored entry, or null if it could not be saved
    • whitelist

      @Nullable Moderation whitelist(FPlayer fPlayer, long time, String reason, int moderator)
      Adds a player to the whitelist.
      Parameters:
      fPlayer - the player to allow in
      time - when the entry expires in milliseconds, or Moderation.PERMANENT_TIME
      reason - the stated reason
      moderator - the issuing player id
      Returns:
      the stored entry, or null if it could not be saved
    • hasValid

      boolean hasValid(FPlayer fTarget, Moderation.Type type)
      Whether a player has an active punishment of the given type.
      Parameters:
      fTarget - the player to check
      type - the punishment type
      Returns:
      true if one is in force
    • hasValid

      boolean hasValid(FPlayer fTarget, Moderation.Type type, int id)
      Whether one specific punishment is still in force.
      Parameters:
      fTarget - the player to check
      type - the punishment type
      id - 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 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 all moderation records matching the criteria
    • getValid

      Optional<Moderation> getValid(FPlayer fPlayer, Moderation.Type type)
      The active punishment of a type for a player.
      Parameters:
      fPlayer - the player to check
      type - 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 check
      type - the punishment type
      server - the server to list from, or null for every server
      limit - how many to return
      offset - how many to skip
      Returns:
      the page
    • getValid

      List<Moderation> getValid(FPlayer fPlayer, Moderation.Type type, int limit, int offset)
      A page of a player's active punishments, for the list commands.
      Parameters:
      fPlayer - the player to check
      type - the punishment type
      limit - how many to return
      offset - how many to skip
      Returns:
      the page
    • getValid

      List<Moderation> getValid(Moderation.Type type, int limit, int offset)
      A page of every active punishment of a type, across all players.
      Parameters:
      type - the punishment type
      limit - how many to return
      offset - how many to skip
      Returns:
      the page
    • getValid

      Optional<Moderation> getValid(Moderation.Type type, int id)
      One active punishment by id.
      Parameters:
      type - the punishment type
      id - the punishment id
      Returns:
      the punishment, or empty if it is not active
    • getValidNames

      List<String> getValidNames(Moderation.Type type)
      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

      int getTotalCount(FPlayer fPlayer, Moderation.Type type, @Nullable String server)
      Counts the total number of moderation records for a player, regardless of validity status.
      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 total count of moderation records matching the criteria
    • getTotalValidCount

      int getTotalValidCount(FPlayer fPlayer, Moderation.Type type, @Nullable String server)
      How many active punishments of a type a player has, used to size the list pages.
      Parameters:
      fPlayer - the player to check
      type - the punishment type
      server - the server to count on, or null for every server
      Returns:
      the count
    • getTotalValidCount

      int getTotalValidCount(Moderation.Type type, @Nullable String server)
      How many active punishments of a type exist in total.
      Parameters:
      type - the punishment type
      server - 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 player
      time - when it expires in milliseconds, or Moderation.PERMANENT_TIME
      reason - the stated reason
      moderator - the issuing player id
      type - 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 player
      date - when it was issued, in milliseconds
      time - when it expires in milliseconds, or Moderation.PERMANENT_TIME
      reason - the stated reason
      moderator - the issuing player id
      type - the punishment type
      server - the server it applies to, or null for every server
      Returns:
      the stored punishment, or null if it could not be saved
    • addViolation

      void addViolation(UUID uuid, ModuleSimple moduleSimple, ViolationSetting violationSetting)
      Records that a player broke a chat rule, which may trip the module's violation limit.
      Parameters:
      uuid - the player id
      moduleSimple - the module whose rule was broken
      violationSetting - the limit settings
    • addViolation

      void addViolation(ModerationService.ViolationKey violationKey, Long violationValue)
      Records a violation directly, used when the count arrives from another server.
      Parameters:
      violationKey - the player and module the count belongs to
      violationValue - 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 id
      moduleSimple - the module whose rule was broken
      violationSetting - the limit settings
      Returns:
      true if the limit has been reached
    • getFirstViolationTimestamp

      Long getFirstViolationTimestamp(UUID uuid, ModuleSimple moduleSimple)
      When the current run of violations started, which is where the limit window is measured from.
      Parameters:
      uuid - the player id
      moduleSimple - 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 it
      fTarget - the punished player
      type - the punishment type
      id - the punishment id, or -1 for the most recent one
      reason - 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 it
      fTarget - the punished player
      type - the punishment type
      id - the punishment id, or -1 for the most recent one
      reason - the stated reason, may be null
      server - 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 it
      fTarget - the punished player
      type - the punishment type
      time - when it stopped applying, in milliseconds
      id - the punishment id, or -1 for the most recent one
      reason - 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 it
      fTarget - the punished player
      type - the punishment type
      time - when it stopped applying, in milliseconds
      id - the punishment id, or -1 for the most recent one
      reason - the stated reason, may be null
      server - the server to revoke it on, or null for every server
      Returns:
      the revoked punishment, or null if there was nothing to revoke
    • isAllowedTime

      boolean isAllowedTime(FPlayer fPlayer, long time, Map<Integer,Long> timeLimits)
      Whether a moderator may issue a punishment of this length, given the per-group limits.
      Parameters:
      fPlayer - the issuing moderator
      time - the requested duration in milliseconds
      timeLimits - the longest duration each group may issue
      Returns:
      true if the duration is allowed
    • hasHigherGroupThan

      boolean hasHigherGroupThan(FPlayer source, FPlayer target)
      Whether one player outranks another, which decides if they may punish them.
      Parameters:
      source - the acting player
      target - the player being acted on
      Returns:
      true if the acting player ranks higher
    • getServer

      String 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.
      Parameters:
      type - the punishment type
      Returns:
      the server name