Class MojangAPI
java.lang.Object
com.cryptomorin.xseries.profiles.mojang.MojangAPI
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic com.mojang.authlib.GameProfilegetCachedProfileByUUID(UUID uuid) Retrieves a cachedGameProfileby UUID from the user cache.static Optional<com.mojang.authlib.GameProfile> getMojangCachedProfileFromUsername(String username) static com.mojang.authlib.GameProfilegetOrFetchProfile(com.mojang.authlib.GameProfile profile) Fetches additional properties for the givenGameProfileif possible (like the texture) and caches the result.static UUIDrequestUsernameToUUID(String username) usernamesToUUIDs(Collection<String> usernames, ProfileRequestConfiguration config)
-
Constructor Details
-
MojangAPI
public MojangAPI()
-
-
Method Details
-
requestUsernameToUUID
- Returns:
- null if a player with that username is not found.
- Throws:
IOException
-
getMojangCachedProfileFromUsername
-
usernamesToUUIDs
public static Map<UUID,String> usernamesToUUIDs(@Nonnull Collection<String> usernames, @Nullable ProfileRequestConfiguration config) -
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
@Nonnull public static com.mojang.authlib.GameProfile getOrFetchProfile(@Nonnull 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.
-