Class MojangAPI
java.lang.Object
com.cryptomorin.xseries.profiles.mojang.MojangAPI
-
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)
-
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) -
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.
-