Class PunishmentReasonProvider

java.lang.Object
de.murmelmeister.murmelapi.punishment.reason.PunishmentReasonProvider
All Implemented Interfaces:
PunishmentReason

public final class PunishmentReasonProvider extends Object implements PunishmentReason
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(int reasonId, int typeId, int executorId, String reason, long duration, boolean autoFlagIp, boolean autoPunish)
    Adds a new punishment reason with the specified details.
    boolean
    exists(int reasonId, int typeId)
    Checks whether a punishment reason exists for the given reason ID and type ID.
    boolean
    getAutoFlagIP(int reasonId, int typeId)
    Retrieves the auto-flag IP status for a specific punishment reason and type.
    boolean
    getAutoPunish(int reasonId, int typeId)
    Retrieves the automatic punishment status for a specific punishment reason and type.
    getCreatedAt(int reasonId, int typeId)
    Retrieves the timestamp indicating when a specific punishment reason was created.
    int
    getCreatedBy(int reasonId, int typeId)
    Retrieves the ID of the user who created the punishment reason.
    long
    getDuration(int reasonId, int typeId)
    Retrieves the duration for the specified punishment reason and type.
    getModifiedAt(int reasonId, int typeId)
    Retrieves the timestamp of the last modification for a specific punishment reason.
    int
    getModifiedBy(int reasonId, int typeId)
    Retrieves the user ID of the person who last modified a specific punishment reason.
    getReason(int reasonId, int typeId)
    Retrieves the reason for a specific punishment based on its reason ID and type ID.
    getReasons(int typeId)
    Retrieves a list of reason IDs associated with the specified type ID.
    void
    remove(int reasonId, int typeId)
    Removes a punishment reason from the system based on the given reason ID and type ID.
    void
    setAutoFlagIP(int reasonId, int typeId, int executorId, boolean autoFlagIp)
    Updates the auto-flagging of an IP address for the given punishment reason and type.
    void
    setAutoPunish(int reasonId, int typeId, int executorId, boolean autoPunish)
    Configures the auto-punishment flag for a specific punishment reason and type.
    void
    setDuration(int reasonId, int typeId, int executorId, long duration)
    Sets the duration of a punishment reason.
    void
    setReason(int reasonId, int typeId, int executorId, String reason)
    Updates the punishment reason for the specified reason ID and type ID.
    static void
    setup(Database database)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PunishmentReasonProvider

      public PunishmentReasonProvider(Database database)
  • Method Details

    • setup

      public static void setup(Database database)
    • exists

      public boolean exists(int reasonId, int typeId)
      Description copied from interface: PunishmentReason
      Checks whether a punishment reason exists for the given reason ID and type ID.
      Specified by:
      exists in interface PunishmentReason
      Parameters:
      reasonId - The unique identifier for the reason
      typeId - The unique identifier for the type
      Returns:
      true if the punishment reason exists, false otherwise
    • add

      public void add(int reasonId, int typeId, int executorId, String reason, long duration, boolean autoFlagIp, boolean autoPunish)
      Description copied from interface: PunishmentReason
      Adds a new punishment reason with the specified details.
      Specified by:
      add in interface PunishmentReason
      Parameters:
      reasonId - The unique identifier for the punishment reason.
      typeId - The identifier for the type of punishment.
      executorId - The identifier of the executor who created the punishment reason.
      reason - The description or explanation of the punishment reason.
      duration - The duration of the punishment in milliseconds; use -1 for indefinite duration.
      autoFlagIp - Whether the system should automatically flag the IP associated with the punishment.
      autoPunish - Whether the system should automatically enforce the punishment.
    • remove

      public void remove(int reasonId, int typeId)
      Description copied from interface: PunishmentReason
      Removes a punishment reason from the system based on the given reason ID and type ID.
      Specified by:
      remove in interface PunishmentReason
      Parameters:
      reasonId - The ID of the punishment reason to be removed
      typeId - The ID of the type associated with the punishment reason
    • getReasons

      public List<Integer> getReasons(int typeId)
      Description copied from interface: PunishmentReason
      Retrieves a list of reason IDs associated with the specified type ID.
      Specified by:
      getReasons in interface PunishmentReason
      Parameters:
      typeId - The ID of the punishment type for which reason IDs should be retrieved
      Returns:
      A list of integer reason IDs associated with the specified type ID
    • getReason

      public String getReason(int reasonId, int typeId)
      Description copied from interface: PunishmentReason
      Retrieves the reason for a specific punishment based on its reason ID and type ID.
      Specified by:
      getReason in interface PunishmentReason
      Parameters:
      reasonId - The unique identifier for the reason.
      typeId - The unique identifier for the type of punishment.
      Returns:
      The reason as a string if it exists, or null if no reason is found.
    • setReason

      public void setReason(int reasonId, int typeId, int executorId, String reason)
      Description copied from interface: PunishmentReason
      Updates the punishment reason for the specified reason ID and type ID.
      Specified by:
      setReason in interface PunishmentReason
      Parameters:
      reasonId - The unique identifier for the punishment reason.
      typeId - The type identifier associated with the punishment reason.
      executorId - The unique identifier of the user who is executing the update.
      reason - The new reason to be set for the punishment.
    • getDuration

      public long getDuration(int reasonId, int typeId)
      Description copied from interface: PunishmentReason
      Retrieves the duration for the specified punishment reason and type.
      Specified by:
      getDuration in interface PunishmentReason
      Parameters:
      reasonId - The unique identifier for the punishment reason
      typeId - The unique identifier for the punishment type
      Returns:
      The duration associated with the specified punishment reason and type, or -1 if not found
    • setDuration

      public void setDuration(int reasonId, int typeId, int executorId, long duration)
      Description copied from interface: PunishmentReason
      Sets the duration of a punishment reason.
      Specified by:
      setDuration in interface PunishmentReason
      Parameters:
      reasonId - The unique identifier for the punishment reason.
      typeId - The type identifier associated with the punishment reason.
      executorId - The unique identifier of the executor who modifies the duration.
      duration - The new duration value to be set for the punishment reason.
    • getAutoFlagIP

      public boolean getAutoFlagIP(int reasonId, int typeId)
      Description copied from interface: PunishmentReason
      Retrieves the auto-flag IP status for a specific punishment reason and type.
      Specified by:
      getAutoFlagIP in interface PunishmentReason
      Parameters:
      reasonId - The unique ID of the punishment reason
      typeId - The type ID associated with the punishment reason
      Returns:
      true if the auto-flag IP feature is enabled for the specified reason and type, false otherwise
    • setAutoFlagIP

      public void setAutoFlagIP(int reasonId, int typeId, int executorId, boolean autoFlagIp)
      Description copied from interface: PunishmentReason
      Updates the auto-flagging of an IP address for the given punishment reason and type.
      Specified by:
      setAutoFlagIP in interface PunishmentReason
      Parameters:
      reasonId - The ID of the punishment reason to update
      typeId - The type ID associated with the punishment reason
      executorId - The ID of the executor performing the update
      autoFlagIp - A boolean indicating whether to enable or disable auto-flagging of the IP
    • getAutoPunish

      public boolean getAutoPunish(int reasonId, int typeId)
      Description copied from interface: PunishmentReason
      Retrieves the automatic punishment status for a specific punishment reason and type.
      Specified by:
      getAutoPunish in interface PunishmentReason
      Parameters:
      reasonId - The unique identifier of the punishment reason
      typeId - The unique identifier of the punishment type
      Returns:
      true if automatic punishment is enabled for the given reason and type, false otherwise
    • setAutoPunish

      public void setAutoPunish(int reasonId, int typeId, int executorId, boolean autoPunish)
      Description copied from interface: PunishmentReason
      Configures the auto-punishment flag for a specific punishment reason and type.
      Specified by:
      setAutoPunish in interface PunishmentReason
      Parameters:
      reasonId - The unique identifier for the punishment reason.
      typeId - The unique identifier for the punishment type.
      executorId - The unique identifier for the executor who is making the change.
      autoPunish - A boolean value indicating whether auto-punishment should be enabled (true) or disabled (false).
    • getCreatedBy

      public int getCreatedBy(int reasonId, int typeId)
      Description copied from interface: PunishmentReason
      Retrieves the ID of the user who created the punishment reason.
      Specified by:
      getCreatedBy in interface PunishmentReason
      Parameters:
      reasonId - The ID of the punishment reason
      typeId - The ID of the punishment type
      Returns:
      The ID of the user who created the punishment reason, or a default value if not found
    • getCreatedAt

      public Timestamp getCreatedAt(int reasonId, int typeId)
      Description copied from interface: PunishmentReason
      Retrieves the timestamp indicating when a specific punishment reason was created.
      Specified by:
      getCreatedAt in interface PunishmentReason
      Parameters:
      reasonId - The unique identifier of the punishment reason.
      typeId - The unique identifier of the punishment type.
      Returns:
      The timestamp representing the creation time of the punishment reason, or null if the reason does not exist.
    • getModifiedBy

      public int getModifiedBy(int reasonId, int typeId)
      Description copied from interface: PunishmentReason
      Retrieves the user ID of the person who last modified a specific punishment reason.
      Specified by:
      getModifiedBy in interface PunishmentReason
      Parameters:
      reasonId - The unique identifier for the punishment reason.
      typeId - The unique identifier for the punishment type.
      Returns:
      The user ID of the person who last modified the specified punishment reason, or -2 if not found.
    • getModifiedAt

      public Timestamp getModifiedAt(int reasonId, int typeId)
      Description copied from interface: PunishmentReason
      Retrieves the timestamp of the last modification for a specific punishment reason.
      Specified by:
      getModifiedAt in interface PunishmentReason
      Parameters:
      reasonId - The ID of the punishment reason
      typeId - The ID of the punishment type
      Returns:
      The timestamp representing when the punishment reason was last modified