Class MojangAPIParser

java.lang.Object
one.tranic.t.base.parse.mojang.MojangAPIParser

public class MojangAPIParser extends Object
MojangAPIParser is a utility class for interacting with the Mojang API to perform profile lookups. It provides methods to retrieve Minecraft profile information by username, UUID, or a batch of usernames. Connections are established using the RequestWithProxyParser class to support proxy configurations.
  • Constructor Details

    • MojangAPIParser

      public MojangAPIParser()
  • Method Details

    • lookupProfile

      public static ProfileLookup lookupProfile(String name) throws IOException
      Retrieves the profile information for a user based on their username.
      Parameters:
      name - the username for which profile information is to be looked up
      Returns:
      a ProfileLookup object containing the profile information
      Throws:
      IOException - if an I/O error occurs during the profile lookup
    • lookupProfile

      public static ProfileLookup lookupProfile(boolean useProxy, String name) throws IOException
      Looks up profile information for a given username from a remote server.
      Parameters:
      useProxy - whether to use a proxy connection for the request
      name - the username to look up
      Returns:
      the ProfileLookup containing the profile ID and name
      Throws:
      IOException - if an I/O error occurs while performing the request or reading the response
    • lookupProfile

      public static ProfileLookup lookupProfile(UUID uuid) throws IOException
      Retrieves the profile information associated with the specified UUID.
      Parameters:
      uuid - the UUID of the profile to lookup; must not be null
      Returns:
      a ProfileLookup containing the profile information corresponding to the given UUID
      Throws:
      IOException - if an I/O error occurs while making the request or processing the response
    • lookupProfile

      public static ProfileLookup lookupProfile(boolean useProxy, UUID uuid) throws IOException
      Looks up a profile from the Mojang API using the specified UUID.
      Parameters:
      useProxy - a boolean indicating whether a proxy should be used for the connection
      uuid - the UUID of the profile to lookup, must not be null
      Returns:
      a ProfileLookup object containing the profile information
      Throws:
      IOException - if an error occurs during the network request or while reading the response
    • lookupProfiles

      public static List<ProfileLookup> lookupProfiles(String... names) throws IOException
      Retrieves a list of profile lookups for the given player names.
      Parameters:
      names - the array of player names to look up profiles for; each name must be a valid string
      Returns:
      a list of ProfileLookup records containing the ID and name of each requested profile
      Throws:
      IOException - if an I/O error occurs during the HTTP request or response parsing
    • lookupProfiles

      public static List<ProfileLookup> lookupProfiles(boolean useProxy, String... names) throws IOException
      Looks up profiles for the given list of names by sending an HTTP request to the Mojang API.
      Parameters:
      useProxy - a boolean indicating whether to use a proxy for the HTTP connection
      names - a variable-length list of usernames to look up profiles for
      Returns:
      a list of ProfileLookup representing the fetched profile information for each provided name
      Throws:
      IOException - if an I/O error occurs while making the request or processing the response