Repository navigation
Platform: ProfileResolver
ProfileResolver is a functional interface responsible for asynchronously resolving a Profile into a fully resolved profile (Profile.Resolved), typically including data like UUID, name, and skin properties.
| Method | Description |
|---|---|
resolveProfile(profile: Profile): CompletableFuture<Profile.Resolved> |
Asynchronously resolves the given profile to a fully resolved profile. |
-
ProfileResolver.mojang():
Returns a resolver implementation that fetches profiles from Mojang’s official API. -
ProfileResolver.caching(delegate: ProfileResolver): ProfileResolver.Cached:
Wraps another resolver adding caching capabilities for faster repeated lookups.
ProfileResolver.Cached extends ProfileResolver and adds methods to query cached results:
| Method | Description |
|---|---|
fromCache(name: String): Profile.Resolved? |
Returns cached profile by name, or null if not cached. |
fromCache(uniqueId: UUID): Profile.Resolved? |
Returns cached profile by UUID, or null if not cached. |
fromCache(profile: Profile): Profile.Resolved? |
Returns cached profile by profile instance, or null. |
You can also implement ProfileResolver.Cached yourself by overriding these methods:
override fun fromCache(name: String): Profile.Resolved? {
// Return cached profile by name or null
}
override fun fromCache(uniqueId: UUID): Profile.Resolved? {
// Return cached profile by UUID or null
}
override fun fromCache(profile: Profile): Profile.Resolved? {
// Return cached profile by Profile or null
}val resolver = ProfileResolver.mojang()
resolver.resolveProfile(profile).thenAccept { resolvedProfile ->
println("Resolved profile UUID: ${resolvedProfile.uniqueId}")
}Or with caching:
val cachedResolver = ProfileResolver.caching(resolver)
cachedResolver.resolveProfile(profile).thenAccept { resolved ->
println("Cached or resolved profile: $resolved")
}You can create your own custom resolver by implementing the interface:
class ProfileResolverCustom : ProfileResolver {
override fun resolveProfile(profile: Profile): CompletableFuture<Profile.Resolved> {
// Your async resolution logic here
}
}Anything unclear or inaccurate? Please let it know by creating an issue.