Class PlayTimeProvider

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

public final class PlayTimeProvider extends Object implements PlayTime
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private static enum 
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addTime(int userId, PlayTimeType type)
    Adds 1 unit of time to the play time of a user with the given user ID and play time type.
    void
    addTime(int userId, PlayTimeType type, long time)
    Adds the specified amount of time to the play time of a user with the given user ID and play time type.
    private void
    createTable(String tableName)
     
    void
    createUser(int userId)
    Creates a new user with the given user ID.
    void
    deleteUser(int userId)
    Deletes a user with the given user ID from the database.
    boolean
    existsUser(int userId)
    Checks if a user with the given user ID exists.
    long
    getTime(int userId, PlayTimeType type)
    Obtains the time for the given user ID and play time type.
    private void
     
    void
    removeTime(int userId, PlayTimeType type)
    Removes the play time for a user with the given user ID and play time type.
    void
    removeTime(int userId, PlayTimeType type, long time)
    Removes the specified amount of time from the play time of a user with the given user ID and play time type.
    void
    resetTime(int userId, PlayTimeType type)
    Resets the play time for a user with the given user ID and play time type.
    void
    setTime(int userId, PlayTimeType type, long time)
    Sets the play time for a user with the given user ID and play time type.
    void
    timer(int userId)
    Starts a timer for the specified user.

    Methods inherited from class java.lang.Object

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

    • PlayTimeProvider

      public PlayTimeProvider(User user)
  • Method Details

    • createTable

      private void createTable(String tableName)
    • existsUser

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

      public void createUser(int userId)
      Description copied from interface: PlayTime
      Creates a new user with the given user ID.
      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 given user ID from the database.
      Specified by:
      deleteUser in interface PlayTime
      Parameters:
      userId - the ID of the user to delete
    • getTime

      public long getTime(int userId, PlayTimeType type)
      Description copied from interface: PlayTime
      Obtains the time for the given user ID and play time type.
      Specified by:
      getTime in interface PlayTime
      Parameters:
      userId - the ID of the user
      type - the type of play time
      Returns:
      the time for the given user ID and play time type
    • setTime

      public void setTime(int userId, PlayTimeType type, long time)
      Description copied from interface: PlayTime
      Sets the play time for a user with the given user ID and play time type.
      Specified by:
      setTime in interface PlayTime
      Parameters:
      userId - the ID of the user
      type - the type of play time
      time - the play time to set for the user
    • addTime

      public void addTime(int userId, PlayTimeType type)
      Description copied from interface: PlayTime
      Adds 1 unit of time to the play time of a user with the given user ID and play time type.
      Specified by:
      addTime in interface PlayTime
      Parameters:
      userId - the ID of the user
      type - the type of play time
    • addTime

      public void addTime(int userId, PlayTimeType type, long time)
      Description copied from interface: PlayTime
      Adds the specified amount of time to the play time of a user with the given user ID and play time type.
      Specified by:
      addTime in interface PlayTime
      Parameters:
      userId - the ID of the user
      type - the type of play time
      time - the amount of time to add to the user's play time, in milliseconds
    • removeTime

      public void removeTime(int userId, PlayTimeType type)
      Description copied from interface: PlayTime
      Removes the 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
      type - the type of play time
    • removeTime

      public void removeTime(int userId, PlayTimeType type, long time)
      Description copied from interface: PlayTime
      Removes the specified amount of time from the play time of a user with the given user ID and play time type.
      Specified by:
      removeTime in interface PlayTime
      Parameters:
      userId - the ID of the user
      type - the type of play time
      time - the amount of time to remove from the user's play time, in milliseconds
    • resetTime

      public void resetTime(int userId, PlayTimeType type)
      Description copied from interface: PlayTime
      Resets the play time for a user with the given user ID and play time type.
      Specified by:
      resetTime in interface PlayTime
      Parameters:
      userId - the ID of the user
      type - the type of play time
    • timer

      public void timer(int userId)
      Description copied from interface: PlayTime
      Starts a timer for the specified user.
      Specified by:
      timer in interface PlayTime
      Parameters:
      userId - the ID of the user for whom to start the timer
    • loadTables

      private void loadTables(User user)