Platform: ProfileResolver - Dani-error/velar GitHub Wiki
๐ค ProfileResolver
ProfileResolver
?
๐ What is 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.
๐ง Interface Overview
Method | Description |
---|---|
resolveProfile(profile: Profile): CompletableFuture<Profile.Resolved> |
Asynchronously resolves the given profile to a fully resolved profile. |
๐ ๏ธ Companion Object Helpers
-
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.
๐๏ธ Caching Interface
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
}
๐ก Usage Example
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
}
}