mirror of
https://github.com/elyby/chrly.git
synced 2024-12-23 21:50:03 +05:30
Добавлена поддержка отображения подписанных текстур
This commit is contained in:
parent
d3b4bee3b0
commit
e652691b29
14
lib/data/SignedTexturesResponse.go
Normal file
14
lib/data/SignedTexturesResponse.go
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package data
|
||||||
|
|
||||||
|
type SignedTexturesResponse struct {
|
||||||
|
Id string `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
IsEly bool `json:"ely,omitempty"`
|
||||||
|
Props []Property `json:"properties"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Property struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Signature string `json:"signature"`
|
||||||
|
Value string `json:"value"`
|
||||||
|
}
|
@ -12,14 +12,17 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SkinItem struct {
|
type SkinItem struct {
|
||||||
UserId int `json:"userId"`
|
UserId int `json:"userId"`
|
||||||
Username string `json:"username"`
|
Uuid string `json:"uuid"`
|
||||||
SkinId int `json:"skinId"`
|
Username string `json:"username"`
|
||||||
Url string `json:"url"`
|
SkinId int `json:"skinId"`
|
||||||
Is1_8 bool `json:"is1_8"`
|
Url string `json:"url"`
|
||||||
IsSlim bool `json:"isSlim"`
|
Is1_8 bool `json:"is1_8"`
|
||||||
Hash string `json:"hash"`
|
IsSlim bool `json:"isSlim"`
|
||||||
oldUsername string
|
Hash string `json:"hash"`
|
||||||
|
MojangTextures string `json:"mojangTextures"`
|
||||||
|
MojangSignature string `json:"mojangSignature"`
|
||||||
|
oldUsername string
|
||||||
}
|
}
|
||||||
|
|
||||||
const accountIdToUsernameKey string = "hash:username-to-account-id"
|
const accountIdToUsernameKey string = "hash:username-to-account-id"
|
||||||
|
40
lib/routes/SignedTextures.go
Normal file
40
lib/routes/SignedTextures.go
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
package routes
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
"net/http"
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
|
"github.com/gorilla/mux"
|
||||||
|
|
||||||
|
"elyby/minecraft-skinsystem/lib/data"
|
||||||
|
"elyby/minecraft-skinsystem/lib/tools"
|
||||||
|
"elyby/minecraft-skinsystem/lib/services"
|
||||||
|
)
|
||||||
|
|
||||||
|
func SignedTextures(w http.ResponseWriter, r *http.Request) {
|
||||||
|
services.Logger.IncCounter("signed_textures.request", 1)
|
||||||
|
username := tools.ParseUsername(mux.Vars(r)["username"])
|
||||||
|
|
||||||
|
rec, err := data.FindSkinByUsername(username)
|
||||||
|
if (err != nil || rec.SkinId == 0) {
|
||||||
|
w.WriteHeader(http.StatusNoContent)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
responseData:= data.SignedTexturesResponse{
|
||||||
|
Id: strings.Replace(rec.Uuid, "-", "", -1),
|
||||||
|
Name: rec.Username,
|
||||||
|
Props: []data.Property{
|
||||||
|
{
|
||||||
|
Name: "textures",
|
||||||
|
Signature: rec.MojangSignature,
|
||||||
|
Value: rec.MojangTextures,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
response,_ := json.Marshal(responseData)
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
w.Write(response)
|
||||||
|
}
|
@ -42,11 +42,14 @@ func handleSkinChanged(model skinChanged) (bool) {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
record.Uuid = model.Uuid
|
||||||
record.SkinId = model.SkinId
|
record.SkinId = model.SkinId
|
||||||
record.Hash = model.Hash
|
record.Hash = model.Hash
|
||||||
record.Is1_8 = model.Is1_8
|
record.Is1_8 = model.Is1_8
|
||||||
record.IsSlim = model.IsSlim
|
record.IsSlim = model.IsSlim
|
||||||
record.Url = model.Url
|
record.Url = model.Url
|
||||||
|
record.MojangTextures = model.MojangTextures
|
||||||
|
record.MojangSignature = model.MojangSignature
|
||||||
|
|
||||||
record.Save()
|
record.Save()
|
||||||
|
|
||||||
|
@ -7,11 +7,14 @@ type usernameChanged struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type skinChanged struct {
|
type skinChanged struct {
|
||||||
AccountId int `json:"userId"`
|
AccountId int `json:"userId"`
|
||||||
SkinId int `json:"skinId"`
|
Uuid string `json:"uuid"`
|
||||||
OldSkinId int `json:"oldSkinId"`
|
SkinId int `json:"skinId"`
|
||||||
Hash string `json:"hash"`
|
OldSkinId int `json:"oldSkinId"`
|
||||||
Is1_8 bool `json:"is1_8"`
|
Hash string `json:"hash"`
|
||||||
IsSlim bool `json:"isSlim"`
|
Is1_8 bool `json:"is1_8"`
|
||||||
Url string `json:"url"`
|
IsSlim bool `json:"isSlim"`
|
||||||
|
Url string `json:"url"`
|
||||||
|
MojangTextures string `json:"mojangTextures"`
|
||||||
|
MojangSignature string `json:"mojangSignature"`
|
||||||
}
|
}
|
||||||
|
@ -85,6 +85,7 @@ func main() {
|
|||||||
router.HandleFunc("/skins/{username}", routes.Skin).Methods("GET").Name("skins")
|
router.HandleFunc("/skins/{username}", routes.Skin).Methods("GET").Name("skins")
|
||||||
router.HandleFunc("/cloaks/{username}", routes.Cape).Methods("GET").Name("cloaks")
|
router.HandleFunc("/cloaks/{username}", routes.Cape).Methods("GET").Name("cloaks")
|
||||||
router.HandleFunc("/textures/{username}", routes.Textures).Methods("GET").Name("textures")
|
router.HandleFunc("/textures/{username}", routes.Textures).Methods("GET").Name("textures")
|
||||||
|
router.HandleFunc("/textures/signed/{username}", routes.SignedTextures).Methods("GET").Name("signedTextures")
|
||||||
router.HandleFunc("/skins/{username}/face", routes.Face).Methods("GET").Name("faces")
|
router.HandleFunc("/skins/{username}/face", routes.Face).Methods("GET").Name("faces")
|
||||||
router.HandleFunc("/skins/{username}/face.png", routes.Face).Methods("GET").Name("faces")
|
router.HandleFunc("/skins/{username}/face.png", routes.Face).Methods("GET").Name("faces")
|
||||||
// Legacy
|
// Legacy
|
||||||
|
Loading…
Reference in New Issue
Block a user