Record Class Moderation

java.lang.Object
java.lang.Record
net.flectone.pulse.model.value.Moderation
Record Components:
id - the database id
player - the punished player id
date - when the punishment was issued, in milliseconds
time - when it expires, in milliseconds, or PERMANENT_TIME
reason - the stated reason, may be null
moderator - the issuing player id
type - what kind of punishment this is
valid - whether it has not been revoked
server - the server it was issued on

public record Moderation(int id, int player, long date, long time, String reason, int moderator, Moderation.Type type, boolean valid, String server) extends Record
A punishment issued by FlectonePulse, such as a ban, mute, warn, kick or whitelist entry.
  • Field Details

    • PERMANENT_TIME

      public static final int PERMANENT_TIME
      The expiry value marking a punishment that never runs out.
      See Also:
  • Constructor Details

    • Moderation

      public Moderation(int id, int player, long date, long time, String reason, int moderator, Moderation.Type type, boolean valid, String server)
      Creates an instance of a Moderation record class.
      Parameters:
      id - the value for the id record component
      player - the value for the player record component
      date - the value for the date record component
      time - the value for the time record component
      reason - the value for the reason record component
      moderator - the value for the moderator record component
      type - the value for the type record component
      valid - the value for the valid record component
      server - the value for the server record component
  • Method Details

    • isActive

      public boolean isActive()
      Whether this punishment still applies, meaning it is neither revoked nor expired.
      Returns:
      true while the punishment is in force
    • isPermanent

      public boolean isPermanent()
      Whether this punishment never expires.
      Returns:
      true if permanent
    • isExpired

      public boolean isExpired()
      Whether the expiry time has passed. Permanent punishments never expire.
      Returns:
      true if the punishment has run out
    • getRemainingTime

      public long getRemainingTime()
      Milliseconds left before this punishment expires.
      Returns:
      the remaining time, or PERMANENT_TIME if permanent
    • getOriginalTime

      public long getOriginalTime()
      The full length the punishment was issued for, rounded to whole seconds.
      Returns:
      the original duration in milliseconds
    • equals

      public boolean equals(Moderation moderation)
      Compares by database id only, ignoring fields that change as the punishment ages.
      Parameters:
      moderation - the punishment to compare against
      Returns:
      true if both refer to the same record
    • withId

      public Moderation withId(int id)
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withPlayer

      public Moderation withPlayer(int player)
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withDate

      public Moderation withDate(long date)
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withTime

      public Moderation withTime(long time)
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withReason

      public Moderation withReason(String reason)
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withModerator

      public Moderation withModerator(int moderator)
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withType

      public Moderation withType(Moderation.Type type)
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withValid

      public Moderation withValid(boolean valid)
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withServer

      public Moderation withServer(String server)
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • id

      public int id()
      Returns the value of the id record component.
      Returns:
      the value of the id record component
    • player

      public int player()
      Returns the value of the player record component.
      Returns:
      the value of the player record component
    • date

      public long date()
      Returns the value of the date record component.
      Returns:
      the value of the date record component
    • time

      public long time()
      Returns the value of the time record component.
      Returns:
      the value of the time record component
    • reason

      public String reason()
      Returns the value of the reason record component.
      Returns:
      the value of the reason record component
    • moderator

      public int moderator()
      Returns the value of the moderator record component.
      Returns:
      the value of the moderator record component
    • type

      public Moderation.Type type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • valid

      public boolean valid()
      Returns the value of the valid record component.
      Returns:
      the value of the valid record component
    • server

      public String server()
      Returns the value of the server record component.
      Returns:
      the value of the server record component