AY 4 роки тому
батько
коміт
a1ff941994

+ 44 - 0
mod/mc/common.go

@@ -0,0 +1,44 @@
+package mc
+
+import (
+	"io"
+	"io/ioutil"
+	"net/http"
+	"os"
+)
+
+func httpReq(url string) []byte {
+	resp, err := http.Get(url)
+	if err != nil {
+		print(err)
+	}
+
+	defer resp.Body.Close()
+	body, err := ioutil.ReadAll(resp.Body)
+	if err != nil {
+		print(err)
+	}
+
+	return body
+}
+
+func downloadFile(filepath string, url string) error {
+
+	// Get the data
+	resp, err := http.Get(url)
+	if err != nil {
+		return err
+	}
+	defer resp.Body.Close()
+
+	// Create the file
+	out, err := os.Create(filepath)
+	if err != nil {
+		return err
+	}
+	defer out.Close()
+
+	// Write the body to file
+	_, err = io.Copy(out, resp.Body)
+	return err
+}

+ 17 - 0
mod/mc/core.go

@@ -0,0 +1,17 @@
+package mc
+
+//Handler is handler
+type Handler struct {
+	UUID     string
+	savePath string
+}
+
+//NewHandler means everythign starts here :)
+func NewHandler(UUID string, savePath string) *Handler {
+	NewlyCreatedHandler := Handler{
+		UUID:     UUID,
+		savePath: savePath,
+	}
+
+	return &NewlyCreatedHandler
+}

+ 18 - 0
mod/mc/skin.go

@@ -0,0 +1,18 @@
+package mc
+
+import (
+	"encoding/base64"
+	"encoding/json"
+)
+
+//DownloadSkin is exported function
+func (mc *Handler) DownloadSkin() {
+	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)
+}

+ 24 - 0
mod/mc/struct.go

@@ -0,0 +1,24 @@
+package mc
+
+type profile struct {
+	ID         string `json:"id"`
+	Name       string `json:"name"`
+	Properties []struct {
+		Name  string `json:"name"`
+		Value string `json:"value"`
+	} `json:"properties"`
+}
+
+type texture struct {
+	Timestamp   int64  `json:"timestamp"`
+	ProfileID   string `json:"profileId"`
+	ProfileName string `json:"profileName"`
+	Textures    struct {
+		SKIN struct {
+			URL string `json:"url"`
+		} `json:"SKIN"`
+		CAPE struct {
+			URL string `json:"url"`
+		} `json:"CAPE"`
+	} `json:"textures"`
+}

BIN
server/logs/.2020-12-16-2 3.log.gz.icloud


+ 13 - 0
server/logs/latest.log

@@ -45,3 +45,16 @@
 [19:17:45] [Server thread/INFO]: Alanyeung left the game
 [19:17:45] [Server thread/INFO]: Kicked Alanyeung: Kicked by an operator
 [19:17:45] [Server thread/WARN]: handleDisconnection() called twice
+[21:26:53] [Server thread/INFO]: Stopping the server
+[21:26:53] [Server thread/INFO]: Stopping server
+[21:26:53] [Server thread/INFO]: Saving players
+[21:26:53] [Server thread/INFO]: Saving worlds
+[21:26:53] [Server thread/INFO]: Saving chunks for level 'ServerLevel[world]'/minecraft:overworld
+[21:26:53] [Server thread/INFO]: ThreadedAnvilChunkStorage (world): All chunks are saved
+[21:26:53] [Server thread/INFO]: Saving chunks for level 'ServerLevel[world]'/minecraft:the_nether
+[21:26:53] [Server thread/INFO]: ThreadedAnvilChunkStorage (DIM-1): All chunks are saved
+[21:26:53] [Server thread/INFO]: Saving chunks for level 'ServerLevel[world]'/minecraft:the_end
+[21:26:53] [Server thread/INFO]: ThreadedAnvilChunkStorage (DIM1): All chunks are saved
+[21:26:53] [Server thread/INFO]: ThreadedAnvilChunkStorage (world): All chunks are saved
+[21:26:53] [Server thread/INFO]: ThreadedAnvilChunkStorage (DIM-1): All chunks are saved
+[21:26:53] [Server thread/INFO]: ThreadedAnvilChunkStorage (DIM1): All chunks are saved

BIN
server/world/DIM-1/data/raids.dat


BIN
server/world/DIM1/data/raids_end.dat


BIN
server/world/data/raids.dat


BIN
server/world/level.dat


BIN
server/world/level.dat_old


BIN
server/world/region/r.-1.-1.mca


BIN
server/world/region/r.-1.0.mca


BIN
server/world/region/r.0.-1.mca