Class OnlineProfileLookup

java.lang.Object
me.pauleff.common.handlers.uuid.OnlineProfileLookup

public final class OnlineProfileLookup extends Object
Resolves online Minecraft player profiles via HTTP API lookups.

Prefer the static one-shot methods for single operations against the process-wide configuration. Use of(ProfileApiConfig) when supplying a custom config, or configure(ProfileApiConfig) once at startup (for example from CLI flags).

  • Method Details

    • of

      public static OnlineProfileLookup of(ProfileApiConfig config)
      Returns a lookup that uses the given API configuration and the default HTTP client.
      Parameters:
      config - the profile API endpoint configuration
      Returns:
      an online profile lookup
      Throws:
      NullPointerException - if config is null
    • of

      public static OnlineProfileLookup of(ProfileApiConfig config, HttpGet http)
      Returns a lookup that uses the given API configuration and HTTP client.
      Parameters:
      config - the profile API endpoint configuration
      http - the HTTP GET client
      Returns:
      an online profile lookup
      Throws:
      NullPointerException - if config or http is null
    • configure

      public static void configure(ProfileApiConfig config)
      Replaces the process-wide lookup used by the static one-shot methods.

      Called once at startup when custom API URLs are provided on the command line.

      Parameters:
      config - the profile API endpoint configuration
      Throws:
      NullPointerException - if config is null
    • current

      public static OnlineProfileLookup current()
      Returns the process-wide lookup installed via configure(ProfileApiConfig), or the Mojang-default lookup when nothing custom was configured.
      Returns:
      the current online profile lookup
    • nameToOnlineUuid

      public static UUID nameToOnlineUuid(String name) throws IOException
      Resolves a player name to an online UUID using the process-wide lookup.
      Parameters:
      name - the Minecraft player name
      Returns:
      the online UUID, or null if no profile or valid UUID was found
      Throws:
      IOException - if the HTTP request fails
    • onlineUuidToName

      public static String onlineUuidToName(UUID uuid) throws IOException
      Resolves an online UUID to a player name using the process-wide lookup.
      Parameters:
      uuid - the online Minecraft player UUID
      Returns:
      the player name, or null if no profile or name was found
      Throws:
      IOException - if the HTTP request fails
    • config

      public ProfileApiConfig config()
      Returns the API configuration used by this lookup.
      Returns:
      the profile API configuration
    • lookupOnlineUuid

      public UUID lookupOnlineUuid(String name) throws IOException
      Resolves a player name to an online (Mojang) UUID via HTTP API lookup.
      Parameters:
      name - the Minecraft player name
      Returns:
      the online UUID, or null if no profile or valid UUID was found
      Throws:
      IOException - if the HTTP request fails
    • lookupName

      public String lookupName(UUID uuid) throws IOException
      Resolves an online UUID to a Minecraft player name via HTTP API lookup.
      Parameters:
      uuid - the online Minecraft player UUID
      Returns:
      the player name, or null if no profile or name was found
      Throws:
      IOException - if the HTTP request fails