Skip to content

Platform: ProfileResolver

Dani ツ edited this page Jun 1, 2025 · 1 revision

👤 ProfileResolver

Source Code


📘 What is 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.


🔧 Interface Overview

Method Description
resolveProfile(profile: Profile): CompletableFuture<Profile.Resolved> Asynchronously resolves the given profile to a fully resolved profile.

🛠️ Companion Object Helpers


🏗️ 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
    }
}

Clone this wiki locally