Interface AvatarSource

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface AvatarSource
Fetches a player's face as PNG bytes, given a UUID.

Optional, and it has a default. Without one wired, the library resolves the skin from Mojang's own session server and crops the face itself, which keeps every alt's identity between the host and Mojang — the two parties already talking during login — rather than disclosing it to a third-party head-render service on every cache miss.

A host that wants a head-render service back, for its 3D renders or its CDN, sets AltsRuntime.Builder#avatarUrlTemplate(String), or implements this seam itself. That is a deliberate choice a host makes, not the default it gets by doing nothing.

Since:
0.10.0
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    avatarPng(String uuid, int sizePx)
    Returns the face for uuid as PNG bytes at roughly sizePx square.
  • Method Details

    • avatarPng

      byte[] avatarPng(String uuid, int sizePx) throws Exception
      Returns the face for uuid as PNG bytes at roughly sizePx square.

      The size is a hint. A source is free to return the closest it has and let the host scale; the cache does not require an exact match.

      Parameters:
      uuid - the dashed or undashed player UUID
      sizePx - the desired face size in pixels
      Returns:
      the PNG bytes, or null when the face could not be produced
      Throws:
      Exception - if the fetch failed in a way worth retrying
      Since:
      0.10.0