Interface Punishment
- All Superinterfaces:
EnforcementOptionsFactory, PunishmentBase, SanctionBase
A full punishment, identifiable by its ID.
See
See
space.arim.libertybans.api.punish for a description of active and
historical punishments.- Author:
- A248
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final InstantA useful constant for theInstantrepresenting a permanent punishment's end date. -
Method Summary
Modifier and TypeMethodDescriptiondefault space.arim.omnibus.util.concurrent.ReactionStage<?> Enforces this punishment.space.arim.omnibus.util.concurrent.ReactionStage<?> enforcePunishment(EnforcementOptions enforcementOptions) Enforces this punishment according to the given options.booleanWhether this punishment is equal to another.Gets the end time of the punishment.default longGets the end time of the punishment, in unix seconds.default intgetID()Deprecated.longGets the unique ID of this punishmentGets the start time of the punishment, which is when the punishment was createddefault longGets the start date of the punishment, in unix secondsdefault booleanConvenience method to determine if this punishment has expired.default booleanConvenience method to determine if this punishment has expired.default booleanConvenience method to determine if this punishment is permanentdefault booleanConvenience method to determine if this punishment is temporary (opposite ofisPermanent())space.arim.omnibus.util.concurrent.ReactionStage<Optional<Punishment>> modifyPunishment(Consumer<PunishmentEditor> editorConsumer) Modifies this punishment and yields the new instance.default space.arim.omnibus.util.concurrent.ReactionStage<Boolean> Undoes and "unenforces" this punishment assuming it active and in the database.space.arim.omnibus.util.concurrent.ReactionStage<Boolean> undoPunishment(EnforcementOptions enforcementOptions) Undoes and "unenforces" this punishment assuming it active and in the database.default space.arim.omnibus.util.concurrent.ReactionStage<?> "Unenforces" this punishment.space.arim.omnibus.util.concurrent.ReactionStage<?> unenforcePunishment(EnforcementOptions enforcementOptions) "Unenforces" this punishment according to the given options.Methods inherited from interface EnforcementOptionsFactory
enforcementOptionsBuilderMethods inherited from interface PunishmentBase
getEscalationTrack, getOperator, getReason, getScope, getType, getVictim
-
Field Details
-
PERMANENT_END_DATE
A useful constant for theInstantrepresenting a permanent punishment's end date. SeegetEndDate().
This constant is provided for readability purposes, but it is interchangeable withInstant.MAX.
-
-
Method Details
-
getID
Deprecated.UsegetIdentifier()insteadGets 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_DATEis used for a permanent punishment- Returns:
- the end date
-
getEndDateSeconds
default long getEndDateSeconds()Gets the end time of the punishment, in unix seconds.0is 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 ofisPermanent())- 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 befalse- Returns:
- true if this is a temporary punishment which has expired
-
isExpired
Convenience method to determine if this punishment has expired. If permanent, will always befalse- 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
Undoes and "unenforces" this punishment assuming it active and in the database.
If the punishment was active then was removed, the future yieldstrue, elsefalse.
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
trueif this punishment existed and was removed and unenforced,falseotherwise
-
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 yieldstrue, elsefalse.
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
trueif this punishment existed and was removed and unenforced,falseotherwise
-
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
Whether this punishment is equal to another. The other punishment must represent the same punishment stored in the database.
Implementations need only checkgetIdentifier()since IDs must always be unique.
-
getIdentifier()instead