Class PlayTimeProvider

java.lang.Object
de.murmelmeister.murmelapi.time.PlayTimeProvider
All Implemented Interfaces:
PlayTime

public final class PlayTimeProvider extends Object implements PlayTime
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addTime(int userId)
    Increments the play time for a user with the specified user ID by one unit.
    void
    addTime(int userId, PlayTimeType type, int time)
    Adds a specified amount of play time for a user based on the given play time type.
    void
    createUser(int userId)
    Creates a user with the specified user ID in the playtime system.
    void
    deleteUser(int userId)
    Deletes a user with the specified user ID from the playtime system.
    boolean
    existsUser(int userId)
    Checks if a user with the specified user ID exists in the playtime system.
    int
    getTime(int userId)
    Retrieves the play time, in seconds, of a user identified by the specified user ID.
    void
    removeTime(int userId)
    Removes one unit of play time from the play time of the user with the specified user ID.
    void
    removeTime(int userId, PlayTimeType type, int time)
    Removes a specified amount of play time for a user with the given user ID and play time type.
    void
    resetTime(int userId)
    Resets the playtime of a user with the specified user ID to zero.
    void
    setTime(int userId, int time)
    Sets the play time for a specific user.
    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

    • PlayTimeProvider

      public PlayTimeProvider(Database database)
  • Method Details

    • setup

      public static void setup(Database database)
    • existsUser

      public boolean existsUser(int userId)
      Description copied from interface: PlayTime
      Checks if a user with the specified user ID exists in the playtime system.
      Specified by:
      existsUser in interface PlayTime
      Parameters:
      userId - The ID of the user to check for existence.
      Returns:
      true if the user exists, false otherwise.
    • createUser

      public void createUser(int userId)
      Description copied from interface: PlayTime
      Creates a user with the specified user ID in the playtime system. If the user already exists, no action is taken.
      Specified by:
      createUser in interface PlayTime
      Parameters:
      userId - The ID of the user to create
    • deleteUser

      public void deleteUser(int userId)
      Description copied from interface: PlayTime
      Deletes a user with the specified user ID from the playtime system.
      Specified by:
      deleteUser in interface PlayTime
      Parameters:
      userId - The ID of the user to delete
    • getTime

      public int getTime(int userId)
      Description copied from interface: PlayTime
      Retrieves the play time, in seconds, of a user identified by the specified user ID.
      Specified by:
      getTime in interface PlayTime
      Parameters:
      userId - The ID of the user whose play time is being retrieved.
      Returns:
      The play time of the user in seconds, or -1 if the user ID does not exist in the database.
    • setTime

      public void setTime(int userId, int time)
      Description copied from interface: PlayTime
      Sets the play time for a specific user.
      Specified by:
      setTime in interface PlayTime
      Parameters:
      userId - The ID of the user whose play time is being set.
      time - The new play time value to set, specified in seconds.
    • addTime

      public void addTime(int userId)
      Description copied from interface: PlayTime
      Increments the play time for a user with the specified user ID by one unit.
      Specified by:
      addTime in interface PlayTime
      Parameters:
      userId - The ID of the user whose play time will be incremented
    • addTime

      public void addTime(int userId, PlayTimeType type, int time)
      Description copied from interface: PlayTime
      Adds a specified amount of play time for a user based on the given play time type.
      Specified by:
      addTime in interface PlayTime
      Parameters:
      userId - The ID of the user whose play time will be increased
      type - The type of play time to be added (e.g., seconds, minutes, hours, etc.)
      time - The amount of play time to add, specified in the given play time type
    • removeTime

      public void removeTime(int userId)
      Description copied from interface: PlayTime
      Removes one unit of play time from the play time of the user with the specified user ID.
      Specified by:
      removeTime in interface PlayTime
      Parameters:
      userId - The ID of the user whose play time will be decreased by one unit
    • removeTime

      public void removeTime(int userId, PlayTimeType type, int time)
      Description copied from interface: PlayTime
      Removes a specified amount of play time for a user with the given user ID and play time type.
      Specified by:
      removeTime in interface PlayTime
      Parameters:
      userId - The ID of the user whose play time will be reduced
      type - The type of play time to be removed (e.g., seconds, minutes, hours)
      time - The amount of time to be removed, specified in the given play time type
    • resetTime

      public void resetTime(int userId)
      Description copied from interface: PlayTime
      Resets the playtime of a user with the specified user ID to zero.
      Specified by:
      resetTime in interface PlayTime
      Parameters:
      userId - The ID of the user whose playtime is to be reset