Class MojangAPI
java.lang.Object
com.cryptomorin.xseries.profiles.mojang.MojangAPI
Note: Wiki.vg is no longer availabe because it was
sunset on November 30, 2024.
Now it's being merged into minecraft.wiki.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull com.mojang.authlib.GameProfilegetCachedProfileByUUID(UUID uuid) Retrieves a cachedGameProfileby UUID from the user cache.static Optional<com.mojang.authlib.GameProfile> getMojangCachedProfileFromUsername(String username) static @NotNull com.mojang.authlib.GameProfilegetOrFetchProfile(@NotNull com.mojang.authlib.GameProfile profile) Fetches additional properties for the givenGameProfileif possible (like the texture) and caches the result.static @Nullable UUIDrequestUsernameToUUID(@NotNull String username) usernamesToUUIDs(@NotNull Collection<String> usernames, @Nullable ProfileRequestConfiguration config) Occasionally a401 - Unauthorizedor403 - Forbiddenerror is received which is not likely caused by rate-limiting because first of all, it'd return429if that was the case, and secondly, the code was run with a 6hr delay.
-
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
-
usernamesToUUIDs
public static Map<UUID,String> usernamesToUUIDs(@NotNull @NotNull Collection<String> usernames, @Nullable @Nullable ProfileRequestConfiguration config) Occasionally a401 - Unauthorizedor403 - Forbiddenerror is received which is not likely caused by rate-limiting because first of all, it'd return429if 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
Retrieves a cachedGameProfileby 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
GameProfilecorresponding 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 givenGameProfileif possible (like the texture) and caches the result.- Parameters:
profile- TheGameProfilefor which properties are to be fetched.- Returns:
- The updated
GameProfilewith fetched properties, sanitized for consistency. - Throws:
UnknownPlayerException- if a player with the specified profile properties (username and UUID) doesn't exist.
-