From 4407f1eb9034300a684b3b9cd611741a8f7645d1 Mon Sep 17 00:00:00 2001 From: illyum Date: Sat, 26 Oct 2024 21:41:05 -0600 Subject: [PATCH] wip: update stuff --- README.md | 47 +++++++++++++++++++++++++++++++++++++++++++++-- app/demo.go | 2 +- config/config.go | 45 +++++++++++++++++++++++++++++++++++++++++++++ hypixel/tst.go | 5 ----- 4 files changed, 91 insertions(+), 8 deletions(-) delete mode 100644 hypixel/tst.go diff --git a/README.md b/README.md index d7c38d0..b3361da 100644 --- a/README.md +++ b/README.md @@ -26,8 +26,51 @@ If you screenshot a leaderboard, it will check the screenshots folder and try to ## Building: + +#### Windows ```bash set CGO_ENABLED=0 go build -ldflags="-s -w" -upx --best --lzma HypixelStuff.exe -``` \ No newline at end of file +upx --best --lzma hudly.exe +``` + +#### Mac (intel x86_64) +```bash +set GOOS=darwin +set GOARCH=amd64 +set CGO_ENABLED=0 +go build -ldflags="-s -w" +upx --best --lzma --force-macos hudly +``` +NOTE: macOS is currently not supported + +#### Mac (apple silicon ARM) +```bash +set GOOS=darwin +set GOARCH=arm64 +set CGO_ENABLED=0 +go build -ldflags="-s -w" +upx --best --lzma --force-macos hudly +``` +NOTE: macOS is currently not supported + + +# TODOS/Limitation +- (api_key) Incorrect structure (api headers don't exist if key is invalid) so you get the wrong error code +- (build) Requires google's UUID library (too big for my liking) +- (client) No keep-alive implemented +- (client) No room closure detection +- (client) You can't see and send data (sender needs to have 2 clients, 1 to host and 1 to read) +- (client/config) Hard coded ip address / port +- (config) No Config (hard code key) +- (demo) Only in-memory uuid cache +- (demo) Lunar Client ONLY (default log location only) +- (demo) Requires working key to function +- (demo) Windows client sender ONLY (not correct log path locator) +- (demo) does NOT show nicked players (doesn't crash) +- (gui) Just terminal for now +- (hypixel_api) No cache +- (player) Only bedwars stats +- (server) Terrible status messages +- (server/server-config) Hard coded port +- (uuid cache) no lifetime (probably isn't needed but still) \ No newline at end of file diff --git a/app/demo.go b/app/demo.go index 20c2edc..2c8f9ec 100644 --- a/app/demo.go +++ b/app/demo.go @@ -1,6 +1,6 @@ package main -var key = "ccebff0f-939a-4afe-b5b3-30a7a665ee38" +var key = "f6999283-43ba-413e-a04d-32dbde98f423" func main() { var demoApp = NewDemoApp(key) diff --git a/config/config.go b/config/config.go index b700341..e069171 100644 --- a/config/config.go +++ b/config/config.go @@ -1,6 +1,9 @@ package config import ( + "encoding/json" + "fmt" + "io/ioutil" "os" "path" "runtime" @@ -67,3 +70,45 @@ func GetDefaultConfig() *Config { }, } } + +// SaveConfig saves the given config struct to the file in JSON format +func SaveConfig(config *Config, filePath string) error { + // Convert the config struct to JSON + data, err := json.MarshalIndent(config, "", " ") + if err != nil { + return fmt.Errorf("failed to serialize config: %v", err) + } + + // Write the JSON data to a file + err = ioutil.WriteFile(filePath, data, 0644) + if err != nil { + return fmt.Errorf("failed to write config to file: %v", err) + } + + return nil +} + +// LoadConfig loads the config from the given file path +func LoadConfig(filePath string) (*Config, error) { + // Check if the file exists + if _, err := os.Stat(filePath); os.IsNotExist(err) { + return nil, fmt.Errorf("config file does not exist: %s", filePath) + } + + // Read the file content + data, err := ioutil.ReadFile(filePath) + if err != nil { + return nil, fmt.Errorf("failed to read config file: %v", err) + } + + // Create a Config object + config := &Config{} + + // Deserialize the JSON data into the Config object + err = json.Unmarshal(data, config) + if err != nil { + return nil, fmt.Errorf("failed to deserialize config: %v", err) + } + + return config, nil +} diff --git a/hypixel/tst.go b/hypixel/tst.go deleted file mode 100644 index 0806e26..0000000 --- a/hypixel/tst.go +++ /dev/null @@ -1,5 +0,0 @@ -package hypixel - -func DoThing() int { - return 1 -}