Interface SkinService


public interface SkinService
Changes the account's skin.

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

Since:
0.11.0
  • Field Details

    • MAX_SKIN_BYTES

      static final int MAX_SKIN_BYTES
      The largest skin, in bytes, an upload will send. A real skin is a few kilobytes; this is far past any, and exists so a wrong file is refused here rather than read whole and posted.
      Since:
      0.12.0
      See Also:
  • Method Details

    • validate

      Optional<SkinProblem> validate(byte[] pngBytes)
      Checks PNG bytes the way upload(byte[], SkinModel) does, without sending anything, and says why they would be refused: the reason a host shows the user, which a AltsFailure.Kind.INVALID_INPUT failure alone does not carry.
      Parameters:
      pngBytes - the candidate skin
      Returns:
      why the bytes are not an uploadable skin, or empty when they are one
      Since:
      1.0.0
    • setFromUrl

      PlayerProfile setFromUrl(String url, SkinModel model)
      Sets the skin from a texture URL Mojang will fetch.
      Parameters:
      url - the skin texture URL
      model - the arm model to render it with
      Returns:
      the updated profile
      Throws:
      AltsException - if the token was refused or the service rejected the skin
      Since:
      0.11.0
    • upload

      PlayerProfile upload(byte[] pngBytes, SkinModel model)
      Uploads a skin from PNG bytes.

      The bytes are checked before anything is sent: they must be a PNG of 64x64 or 64x32 pixels, no larger than MAX_SKIN_BYTES. One that is not fails with an AltsException of kind AltsFailure.Kind.INVALID_INPUT; validate(byte[]) says which check it failed.

      Parameters:
      pngBytes - the skin PNG
      model - the arm model to render it with
      Returns:
      the updated profile
      Throws:
      AltsException - of kind INVALID_INPUT if the bytes are not an uploadable skin (nothing was sent), or of the kind the refusal was if the service refused or failed
      Since:
      0.11.0
    • upload

      default PlayerProfile upload(Path pngFile, SkinModel model)
      Uploads a skin from a PNG file, with the same checks as upload(byte[], SkinModel).

      No failure this raises names the file: a path on the user's disk says where they keep things and under what account name, and failure messages are what a host shows and logs.

      A file that is missing, unreadable or not an uploadable skin fails with kind AltsFailure.Kind.INVALID_INPUT, which does not say which check it failed. A host that wants the reason to show reads the bytes itself and calls validate(byte[]) on them; there is no validate(Path).

      Parameters:
      pngFile - the skin PNG file
      model - the arm model to render it with
      Returns:
      the updated profile
      Throws:
      AltsException - of kind INVALID_INPUT if the file cannot be read or is not an uploadable skin (nothing was sent), or of the kind the refusal was if the service refused or failed
      UnsupportedOperationException - if this implementation predates file uploads
      Since:
      0.12.0
    • reset

      void reset()
      Resets the skin to the default, removing any custom one.
      Throws:
      AltsException - if the token was refused or the service failed
      Since:
      0.11.0
    • resetToDefault

      default PlayerProfile resetToDefault()
      Resets the skin to the default and returns the profile as it stands afterwards, the way the other mutations here do.
      Returns:
      the updated profile, or null when the service confirmed the reset without sending one back
      Throws:
      AltsException - if the token was refused or the service failed
      Since:
      0.12.0