123456789101112131415161718192021222324 |
- package mc
- import (
- "encoding/base64"
- "encoding/json"
- "log"
- "os"
- )
- //DownloadSkin is exported function
- func (mc *Handler) DownloadSkin() {
- if _, err := os.Stat(mc.savePath + "/" + mc.UUID + ".png"); os.IsNotExist(err) {
- resp := httpReq("https://sessionserver.mojang.com/session/minecraft/profile/" + mc.UUID)
- var profileArray profile
- json.Unmarshal(resp, &profileArray)
- decoded, _ := base64.URLEncoding.DecodeString(profileArray.Properties[0].Value)
- var textureArray texture
- json.Unmarshal([]byte(decoded), &textureArray)
- downloadFile(mc.savePath+"/"+mc.UUID+".png", textureArray.Textures.SKIN.URL)
- } else {
- log.Println("Skin exists, not downloading")
- }
- }
|