Class UserProvider

java.lang.Object
de.murmelmeister.murmelapi.user.UserProvider
All Implemented Interfaces:
User

public final class UserProvider extends Object implements User
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Creates a new user with the specified username if it does not already exist, or retrieves the ID of an existing user with the specified username.
    int
    Creates a new user with the specified UUID if it does not already exist, or retrieves the ID of an existing user associated with the specified UUID.
    void
    createUser(UUID uuid, String username)
    Creates a new user in the system based on the provided UUID and username.
    void
    Deletes a user associated with the specified UUID.
    boolean
    existsUser(String username)
    Checks if a user with the specified username exists.
    boolean
    Checks if a user with the specified UUID exists.
    getFirstJoinDate(int userId)
    Retrieves the first join date of a user as a formatted date string.
    getFirstJoinTime(int userId)
    Retrieves the first join time of a user in milliseconds since the epoch.
    int
    getId(String username)
    Retrieves the unique numeric ID of a user associated with the specified username.
    int
    getId(UUID uuid)
    Retrieves the unique numeric ID of a user associated with the specified UUID.
    Retrieves the parent information associated with the user.
    Retrieves the permission associated with a user.
    getUniqueId(int userId)
    Retrieves the unique identifier (UUID) associated with the specified user ID.
    getUniqueId(String username)
    Retrieves the unique identifier (UUID) associated with the specified username.
    Retrieves a list of unique identifiers (UUIDs) associated with all users.
    getUsername(int userId)
    Retrieves the username associated with the specified user ID.
    Retrieves the username associated with the specified UUID.
    Retrieves a list of usernames for all users.
    void
    joinUser(UUID uuid, String username)
    Joins the user identified by the specified UUID and username into the system.
    void
    Loads and processes expired user data in the system.
    void
    rename(int userId, String newUsername)
    Renames a user by updating the username associated with the given user ID.
    void
    rename(UUID uuid, String newUsername)
    Updates the username of the user associated with the specified UUID.
    void
    setFirstJoinTime(int userId)
    Sets the first join time for a user identified by the given user 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

    • UserProvider

      public UserProvider(Database database)
  • Method Details

    • setup

      public static void setup(Database database)
    • createOrGetUser

      public int createOrGetUser(String username)
      Description copied from interface: User
      Creates a new user with the specified username if it does not already exist, or retrieves the ID of an existing user with the specified username.
      Specified by:
      createOrGetUser in interface User
      Parameters:
      username - The username of the user to create or retrieve
      Returns:
      The unique numeric ID of the newly created or existing user
    • createOrGetUser

      public int createOrGetUser(UUID uuid)
      Description copied from interface: User
      Creates a new user with the specified UUID if it does not already exist, or retrieves the ID of an existing user associated with the specified UUID.
      Specified by:
      createOrGetUser in interface User
      Parameters:
      uuid - The unique identifier of the user to create or retrieve
      Returns:
      The unique numeric ID of the newly created or existing user
    • existsUser

      public boolean existsUser(UUID uuid)
      Description copied from interface: User
      Checks if a user with the specified UUID exists.
      Specified by:
      existsUser in interface User
      Parameters:
      uuid - The unique identifier of the user to check
      Returns:
      True if a user with the given UUID exists, false otherwise
    • existsUser

      public boolean existsUser(String username)
      Description copied from interface: User
      Checks if a user with the specified username exists.
      Specified by:
      existsUser in interface User
      Parameters:
      username - The username of the user to check
      Returns:
      True if a user with the given username exists, false otherwise
    • createUser

      public void createUser(UUID uuid, String username)
      Description copied from interface: User
      Creates a new user in the system based on the provided UUID and username. If the user already exists, no new user will be created.
      Specified by:
      createUser in interface User
      Parameters:
      uuid - The unique identifier of the user to be created
      username - The username of the user to be created
    • deleteUser

      public void deleteUser(UUID uuid)
      Description copied from interface: User
      Deletes a user associated with the specified UUID.
      Specified by:
      deleteUser in interface User
      Parameters:
      uuid - The unique identifier of the user to be deleted
    • getId

      public int getId(UUID uuid)
      Description copied from interface: User
      Retrieves the unique numeric ID of a user associated with the specified UUID.
      Specified by:
      getId in interface User
      Parameters:
      uuid - The unique identifier of the user whose ID is to be retrieved
      Returns:
      The unique numeric ID of the user associated with the given UUID
    • getId

      public int getId(String username)
      Description copied from interface: User
      Retrieves the unique numeric ID of a user associated with the specified username.
      Specified by:
      getId in interface User
      Parameters:
      username - The username of the user whose ID is to be retrieved
      Returns:
      The unique numeric ID of the user associated with the given username
    • getUniqueId

      public UUID getUniqueId(int userId)
      Description copied from interface: User
      Retrieves the unique identifier (UUID) associated with the specified user ID. If no user exists with the given ID, the behavior may vary depending on the implementation.
      Specified by:
      getUniqueId in interface User
      Parameters:
      userId - The unique numeric ID of the user
      Returns:
      The UUID associated with the specified user ID
    • getUniqueId

      public UUID getUniqueId(String username)
      Description copied from interface: User
      Retrieves the unique identifier (UUID) associated with the specified username. If no user exists with the given username, the behavior may vary depending on the implementation.
      Specified by:
      getUniqueId in interface User
      Parameters:
      username - The username of the user whose UUID is to be retrieved
      Returns:
      The UUID associated with the specified username
    • getUsername

      public String getUsername(int userId)
      Description copied from interface: User
      Retrieves the username associated with the specified user ID.
      Specified by:
      getUsername in interface User
      Parameters:
      userId - The unique numeric ID of the user whose username is to be retrieved
      Returns:
      The username associated with the given user ID
    • getUsername

      public String getUsername(UUID uuid)
      Description copied from interface: User
      Retrieves the username associated with the specified UUID.
      Specified by:
      getUsername in interface User
      Parameters:
      uuid - The unique identifier of the user whose username is to be retrieved
      Returns:
      The username associated with the given UUID
    • rename

      public void rename(int userId, String newUsername)
      Description copied from interface: User
      Renames a user by updating the username associated with the given user ID.
      Specified by:
      rename in interface User
      Parameters:
      userId - The unique numeric ID of the user whose username is to be updated
      newUsername - The new username to associate with the user
    • rename

      public void rename(UUID uuid, String newUsername)
      Description copied from interface: User
      Updates the username of the user associated with the specified UUID.
      Specified by:
      rename in interface User
      Parameters:
      uuid - The unique identifier of the user to be updated
      newUsername - The new username to assign to the user
    • getUniqueIds

      public List<UUID> getUniqueIds()
      Description copied from interface: User
      Retrieves a list of unique identifiers (UUIDs) associated with all users.
      Specified by:
      getUniqueIds in interface User
      Returns:
      A list of UUIDs representing all users.
    • getUsernames

      public List<String> getUsernames()
      Description copied from interface: User
      Retrieves a list of usernames for all users.
      Specified by:
      getUsernames in interface User
      Returns:
      A list of usernames representing all users.
    • getFirstJoinTime

      public Timestamp getFirstJoinTime(int userId)
      Description copied from interface: User
      Retrieves the first join time of a user in milliseconds since the epoch.
      Specified by:
      getFirstJoinTime in interface User
      Parameters:
      userId - The unique numeric ID of the user
      Returns:
      The first join time of the user in milliseconds since January 1, 1970, 00:00:00 GMT
    • getFirstJoinDate

      public String getFirstJoinDate(int userId)
      Description copied from interface: User
      Retrieves the first join date of a user as a formatted date string.
      Specified by:
      getFirstJoinDate in interface User
      Parameters:
      userId - The unique numeric ID of the user whose first join date is to be retrieved
      Returns:
      A string representing the first join date of the user
    • setFirstJoinTime

      public void setFirstJoinTime(int userId)
      Description copied from interface: User
      Sets the first join time for a user identified by the given user ID.
      Specified by:
      setFirstJoinTime in interface User
      Parameters:
      userId - The unique numeric ID of the user whose first join time is to be set
    • joinUser

      public void joinUser(UUID uuid, String username)
      Description copied from interface: User
      Joins the user identified by the specified UUID and username into the system.
      Specified by:
      joinUser in interface User
      Parameters:
      uuid - The unique identifier associated with the user to join
      username - The username of the user to join
    • loadExpired

      public void loadExpired()
      Description copied from interface: User
      Loads and processes expired user data in the system. This method handles expired or outdated user records, executing relevant operations such as cleanup, refresh, or other maintenance tasks depending on the specific implementation.
      Specified by:
      loadExpired in interface User
    • getParent

      public UserParent getParent()
      Description copied from interface: User
      Retrieves the parent information associated with the user.
      Specified by:
      getParent in interface User
      Returns:
      A UserParent object representing the parent information of the user.
    • getPermission

      public UserPermission getPermission()
      Description copied from interface: User
      Retrieves the permission associated with a user.
      Specified by:
      getPermission in interface User
      Returns:
      The UserPermission object representing the user's permissions.