Interface SkinService
Not designed for host implementation; methods may be added in minor releases.
- Since:
- 0.11.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe largest skin, in bytes, an upload will send. -
Method Summary
Modifier and TypeMethodDescriptionvoidreset()Resets the skin to the default, removing any custom one.default PlayerProfileResets the skin to the default and returns the profile as it stands afterwards, the way the other mutations here do.setFromUrl(String url, SkinModel model) Sets the skin from a texture URL Mojang will fetch.Uploads a skin from PNG bytes.default PlayerProfileUploads a skin from a PNG file, with the same checks asupload(byte[], SkinModel).validate(byte[] pngBytes) Checks PNG bytes the wayupload(byte[], SkinModel)does, without sending anything, and says why they would be refused: the reason a host shows the user, which aAltsFailure.Kind.INVALID_INPUTfailure alone does not carry.
-
Field Details
-
MAX_SKIN_BYTES
static final int MAX_SKIN_BYTESThe 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
Checks PNG bytes the wayupload(byte[], SkinModel)does, without sending anything, and says why they would be refused: the reason a host shows the user, which aAltsFailure.Kind.INVALID_INPUTfailure 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
Sets the skin from a texture URL Mojang will fetch.- Parameters:
url- the skin texture URLmodel- 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
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 anAltsExceptionof kindAltsFailure.Kind.INVALID_INPUT;validate(byte[])says which check it failed.- Parameters:
pngBytes- the skin PNGmodel- the arm model to render it with- Returns:
- the updated profile
- Throws:
AltsException- of kindINVALID_INPUTif 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
Uploads a skin from a PNG file, with the same checks asupload(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 callsvalidate(byte[])on them; there is novalidate(Path).- Parameters:
pngFile- the skin PNG filemodel- the arm model to render it with- Returns:
- the updated profile
- Throws:
AltsException- of kindINVALID_INPUTif 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 failedUnsupportedOperationException- 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
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
nullwhen the service confirmed the reset without sending one back - Throws:
AltsException- if the token was refused or the service failed- Since:
- 0.12.0
-