Interface Punishment

All Superinterfaces:
EnforcementOptionsFactory, PunishmentBase, SanctionBase

public interface Punishment extends PunishmentBase, EnforcementOptionsFactory
A full punishment, identifiable by its ID.

See space.arim.libertybans.api.punish for a description of active and historical punishments.
Author:
A248
  • Field Details

    • PERMANENT_END_DATE

      static final Instant PERMANENT_END_DATE
      A useful constant for the Instant representing a permanent punishment's end date. See getEndDate().

      This constant is provided for readability purposes, but it is interchangeable with Instant.MAX.
  • Method Details

    • getID

      @Deprecated default int getID()
      Deprecated.
      Use getIdentifier() instead
      Gets the unique ID of this punishment
      Returns:
      the ID of the punishment
    • getIdentifier

      long getIdentifier()
      Gets the unique ID of this punishment
      Returns:
      the ID of the punishment
    • getStartDate

      Instant getStartDate()
      Gets the start time of the punishment, which is when the punishment was created
      Returns:
      the state date
    • getStartDateSeconds

      default long getStartDateSeconds()
      Gets the start date of the punishment, in unix seconds
      Returns:
      the start date seconds
    • getEndDate

      Instant getEndDate()
      Gets the end time of the punishment. PERMANENT_END_DATE is used for a permanent punishment
      Returns:
      the end date
    • getEndDateSeconds

      default long getEndDateSeconds()
      Gets the end time of the punishment, in unix seconds. 0 is used for a permanent punishment
      Returns:
      the end date seconds
    • isPermanent

      default boolean isPermanent()
      Convenience method to determine if this punishment is permanent
      Returns:
      true if this punishment is permanent, false otherwise
    • isTemporary

      default boolean isTemporary()
      Convenience method to determine if this punishment is temporary (opposite of isPermanent())
      Returns:
      true if this punishment is temporary, false otherwise
    • isExpired

      default boolean isExpired()
      Convenience method to determine if this punishment has expired. If permanent, will always be false
      Returns:
      true if this is a temporary punishment which has expired
    • isExpired

      default boolean isExpired(Clock clock)
      Convenience method to determine if this punishment has expired. If permanent, will always be false
      Parameters:
      clock - the clock to use
      Returns:
      true if this is a temporary punishment which has expired
    • enforcePunishment

      default space.arim.omnibus.util.concurrent.ReactionStage<?> enforcePunishment()
      Enforces this punishment.

      For bans and mutes, this will kick players matching the punishment's victim. For mutes and warn, the players will be sent a warning message.
      Additionally for mutes, the player will be unable to chat (depending on the implementation) until the mute cache expires, at which point the database is re-queried for a mute.
      Returns:
      a future completed when enforcement has been conducted
    • enforcePunishment

      space.arim.omnibus.util.concurrent.ReactionStage<?> enforcePunishment(EnforcementOptions enforcementOptions)
      Enforces this punishment according to the given options.

      For bans and mutes, this will kick players matching the punishment's victim. For mutes and warn, the players will be sent a warning message.
      Additionally for mutes, the player will be unable to chat (depending on the implementation) until the mute cache expires, at which point the database is re-queried for a mute.
      Parameters:
      enforcementOptions - the enforcement options. Can be used to disable unenforcement entirely
      Returns:
      a future completed when enforcement has been conducted
    • undoPunishment

      default space.arim.omnibus.util.concurrent.ReactionStage<Boolean> undoPunishment()
      Undoes and "unenforces" this punishment assuming it active and in the database.
      If the punishment was active then was removed, the future yields true, else false.

      Unenforcement implies purging of this punishment from any local caches. Additionally, any relevant broadcast messages will be sent to players.
      Returns:
      a future which yields true if this punishment existed and was removed and unenforced, false otherwise
    • undoPunishment

      space.arim.omnibus.util.concurrent.ReactionStage<Boolean> undoPunishment(EnforcementOptions enforcementOptions)
      Undoes and "unenforces" this punishment assuming it active and in the database.
      If the punishment was active then was removed, the future yields true, else false.

      Unenforcement implies purging of this punishment from any local caches. Additionally, any relevant broadcast messages will be sent to players.
      Parameters:
      enforcementOptions - the enforcement options. Can be used to disable unenforcement entirely
      Returns:
      a future which yields true if this punishment existed and was removed and unenforced, false otherwise
    • unenforcePunishment

      default space.arim.omnibus.util.concurrent.ReactionStage<?> unenforcePunishment()
      "Unenforces" this punishment.

      Unenforcement may mean purging caches such as the mute cache.
      Returns:
      a future completed when unenforcement has been conducted
    • unenforcePunishment

      space.arim.omnibus.util.concurrent.ReactionStage<?> unenforcePunishment(EnforcementOptions enforcementOptions)
      "Unenforces" this punishment according to the given options.

      Unenforcement may mean purging caches such as the mute cache.
      Parameters:
      enforcementOptions - the enforcement options. Can be used to disable unenforcement entirely
      Returns:
      a future completed when unenforcement has been conducted
    • modifyPunishment

      space.arim.omnibus.util.concurrent.ReactionStage<Optional<Punishment>> modifyPunishment(Consumer<PunishmentEditor> editorConsumer)
      Modifies this punishment and yields the new instance.

      This punishment instance is invalidated by use of this method. The new punishment returned should be used as soon as it becomes available.
      Parameters:
      editorConsumer - the actions applied to modify this punishment. Note that the editor is made invalid as soon as the consumer exits scope.
      Returns:
      the new punishment after changes have been propagated to the database, or an empty optional if the punishment has since been expunged
    • equals

      boolean equals(Object object)
      Whether this punishment is equal to another. The other punishment must represent the same punishment stored in the database.

      Implementations need only check getIdentifier() since IDs must always be unique.
      Overrides:
      equals in class Object
      Parameters:
      object - the other object
      Returns:
      true if the objects are equal, false otherwise