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"`
|
||||
}
|
@ -13,12 +13,15 @@ import (
|
||||
|
||||
type SkinItem struct {
|
||||
UserId int `json:"userId"`
|
||||
Uuid string `json:"uuid"`
|
||||
Username string `json:"username"`
|
||||
SkinId int `json:"skinId"`
|
||||
Url string `json:"url"`
|
||||
Is1_8 bool `json:"is1_8"`
|
||||
IsSlim bool `json:"isSlim"`
|
||||
Hash string `json:"hash"`
|
||||
MojangTextures string `json:"mojangTextures"`
|
||||
MojangSignature string `json:"mojangSignature"`
|
||||
oldUsername string
|
||||
}
|
||||
|
||||
|
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
|
||||
}
|
||||
|
||||
record.Uuid = model.Uuid
|
||||
record.SkinId = model.SkinId
|
||||
record.Hash = model.Hash
|
||||
record.Is1_8 = model.Is1_8
|
||||
record.IsSlim = model.IsSlim
|
||||
record.Url = model.Url
|
||||
record.MojangTextures = model.MojangTextures
|
||||
record.MojangSignature = model.MojangSignature
|
||||
|
||||
record.Save()
|
||||
|
||||
|
@ -8,10 +8,13 @@ type usernameChanged struct {
|
||||
|
||||
type skinChanged struct {
|
||||
AccountId int `json:"userId"`
|
||||
Uuid string `json:"uuid"`
|
||||
SkinId int `json:"skinId"`
|
||||
OldSkinId int `json:"oldSkinId"`
|
||||
Hash string `json:"hash"`
|
||||
Is1_8 bool `json:"is1_8"`
|
||||
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("/cloaks/{username}", routes.Cape).Methods("GET").Name("cloaks")
|
||||
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.png", routes.Face).Methods("GET").Name("faces")
|
||||
// Legacy
|
||||
|
Loading…
Reference in New Issue
Block a user