Class MojangAPI

java.lang.Object
com.cryptomorin.xseries.profiles.mojang.MojangAPI

@Internal public final class MojangAPI extends Object
  • Constructor Details

    • MojangAPI

      public MojangAPI()
  • Method Details

    • requestUsernameToUUID

      @Nullable public static UUID requestUsernameToUUID(@Nonnull String username) throws IOException
      Returns:
      null if a player with that username is not found.
      Throws:
      IOException
    • getMojangCachedProfileFromUsername

      public static Optional<com.mojang.authlib.GameProfile> getMojangCachedProfileFromUsername(String username)
    • usernamesToUUIDs

      public static Map<UUID,String> usernamesToUUIDs(@Nonnull Collection<String> usernames, @Nullable ProfileRequestConfiguration config)
    • getCachedProfileByUUID

      @Nonnull public static com.mojang.authlib.GameProfile getCachedProfileByUUID(UUID uuid)
      Retrieves a cached GameProfile by UUID from the user cache. If the profile is not found in the cache, creates a new profile with the provided UUID.
      Parameters:
      uuid - The UUID of the profile to retrieve from the cache.
      Returns:
      The cached GameProfile corresponding to the UUID, or a new profile if not found.
    • getOrFetchProfile

      @Nonnull public static com.mojang.authlib.GameProfile getOrFetchProfile(@Nonnull com.mojang.authlib.GameProfile profile) throws UnknownPlayerException
      Fetches additional properties for the given GameProfile if possible (like the texture) and caches the result.
      Parameters:
      profile - The GameProfile for which properties are to be fetched.
      Returns:
      The updated GameProfile with fetched properties, sanitized for consistency.
      Throws:
      UnknownPlayerException - if a player with the specified profile properties (username and UUID) doesn't exist.