Interface ProfileService


public interface ProfileService
Reads an account's full Minecraft profile — name, UUID, skins, capes, and any pending moderation actions — and creates one for an entitled account that has none. The slim name-and-UUID read the auth chain performs is separate and internal; this is the whole picture a host shows.

Not designed for host implementation; methods may be added in minor releases.

Since:
0.11.0
  • Method Summary

    Modifier and Type
    Method
    Description
    create(String name)
    Creates the profile of an entitled account that does not have one yet, under the given name.
    Fetches the full profile.
    Fetches the full profile, treating "this account has no profile" as an answer rather than a failure.
  • Method Details

    • fetch

      PlayerProfile fetch()
      Fetches the full profile.

      An account with no profile (the service answers 404) fails this with kind AltsFailure.Kind.NOT_ENTITLED, as sign-in and check report it; fetchIfPresent() is the form that treats it as an answer.

      Returns:
      the profile
      Throws:
      AltsException - if the token was refused, the account has no profile, or the service failed
      Since:
      0.11.0
    • fetchIfPresent

      default Optional<PlayerProfile> fetchIfPresent()
      Fetches the full profile, treating "this account has no profile" as an answer rather than a failure.

      An account can authenticate perfectly well and still have no profile: it owns nothing, or it is entitled — through a subscription, say — and has never chosen a name. The profile read alone cannot tell those two apart; pair an empty result with EntitlementService.fetch(), and where the account is entitled, create(String) is what gives it a profile.

      Returns:
      the profile, or empty when the account has none
      Throws:
      AltsException - if the token was refused or the service failed
      Since:
      0.12.0
    • create

      default ProfileCreationResult create(String name)
      Creates the profile of an entitled account that does not have one yet, under the given name.

      The name is checked locally first — three to sixteen letters, digits, or underscores — and one that could never be accepted is reported as ProfileCreationResult.Outcome.INVALID_NAME without a request being sent.

      Never throws for a refusal or an unreachable service: each is a ProfileCreationResult, a failure being ProfileCreationResult.Outcome.FAILED with its kind.

      Parameters:
      name - the username to create the profile with
      Returns:
      the classified outcome, carrying the new profile on success
      Throws:
      UnsupportedOperationException - if this implementation predates profile creation
      Since:
      0.12.0