Class MojangAPI

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

@Internal public final class MojangAPI extends Object
Note: Wiki.vg is no longer availabe because it was sunset on November 30, 2024. Now it's being merged into minecraft.wiki.
  • Constructor Details

    • MojangAPI

      public MojangAPI()
  • Method Details

    • requestUsernameToUUID

      @Nullable public static @Nullable UUID requestUsernameToUUID(@NotNull @NotNull 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(@NotNull @NotNull Collection<String> usernames, @Nullable @Nullable ProfileRequestConfiguration config)
      Occasionally a 401 - Unauthorized or 403 - Forbidden error is received which is not likely caused by rate-limiting because first of all, it'd return 429 if that was the case, and secondly, the code was run with a 6hr delay. It's currently unknown why this happens. In these cases, the raw URL returns this JSON response:
      
       {
         "path" : "/minecraft/profile/lookup/bulk/byname",
         "error" : "METHOD_NOT_ALLOWED",
         "errorMessage" : "Method Not Allowed"
       }
       
      Parameters:
      usernames - Case-insensitive list of usernames. Duplicates are ignored and cached names are not requested but returned.
      config - Request configuration.
      Returns:
      Map of players that exist.
    • getCachedProfileByUUID

      @NotNull public static @NotNull 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

      @NotNull public static @NotNull com.mojang.authlib.GameProfile getOrFetchProfile(@NotNull @NotNull 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.