skin.go 521 B

123456789101112131415161718
  1. package mc
  2. import (
  3. "encoding/base64"
  4. "encoding/json"
  5. )
  6. //DownloadSkin is exported function
  7. func (mc *Handler) DownloadSkin() {
  8. resp := httpReq("https://sessionserver.mojang.com/session/minecraft/profile/" + mc.UUID)
  9. var profileArray profile
  10. json.Unmarshal(resp, &profileArray)
  11. decoded, _ := base64.URLEncoding.DecodeString(profileArray.Properties[0].Value)
  12. var textureArray texture
  13. json.Unmarshal([]byte(decoded), &textureArray)
  14. downloadFile(mc.savePath+"/"+mc.UUID+".png", textureArray.Textures.SKIN.URL)
  15. }