From c1d88d82888d4ba919388daa05a4ab3e5ef4dfcb Mon Sep 17 00:00:00 2001 From: cyber-dream Date: Sun, 12 Feb 2023 02:06:53 +0300 Subject: [PATCH 1/4] add mod file --- go.mod | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 go.mod diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..b23aa27 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module git.gregbrzezinski.com/Skirda/sharedutils + +go 1.18 From 4d926b1cfdbb0d3d2534ecc46225d18719de0c84 Mon Sep 17 00:00:00 2001 From: denver Date: Sun, 12 Feb 2023 02:15:55 +0300 Subject: [PATCH 2/4] add structures file for minecraft --- games/minecraftgame/structures.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 games/minecraftgame/structures.go diff --git a/games/minecraftgame/structures.go b/games/minecraftgame/structures.go new file mode 100644 index 0000000..5b2fbbc --- /dev/null +++ b/games/minecraftgame/structures.go @@ -0,0 +1,17 @@ +package minecraftgame + +type JavaVersion struct { + Version `json:"version"` + Specifics []struct { + Os string `json:"os"` + Arch string `json:"arch"` + URL string `json:"URL"` + Sha1 string `json:"SHA1"` + } `json:"specifics"` +} + +type Version struct { + Major string `json:"major"` + Minor string `json:"minor"` + Patch string `json:"patch"` +} From eb875ad3d233be5318de7e2448005e817a6cf153 Mon Sep 17 00:00:00 2001 From: cyber-dream Date: Sun, 12 Feb 2023 02:33:58 +0300 Subject: [PATCH 3/4] fix imports --- domain/domain.go | 4 ++-- games/minecraftgame/minecraftgame.go | 2 +- games/steamgame/steamgame.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/domain/domain.go b/domain/domain.go index 995b6b5..43b0ab9 100644 --- a/domain/domain.go +++ b/domain/domain.go @@ -3,8 +3,8 @@ package domain import ( "errors" - "git.gregbrzezinski.com/Skirda/skirdaGoLauncher/sharedutils/games/skirdagame" - "git.gregbrzezinski.com/Skirda/skirdaGoLauncher/sharedutils/skirdasession" + "git.gregbrzezinski.com/Skirda/sharedutils/games/skirdagame" + "git.gregbrzezinski.com/Skirda/sharedutils/skirdasession" ) type SkirdaDomain struct { diff --git a/games/minecraftgame/minecraftgame.go b/games/minecraftgame/minecraftgame.go index 76af011..648708b 100644 --- a/games/minecraftgame/minecraftgame.go +++ b/games/minecraftgame/minecraftgame.go @@ -1,6 +1,6 @@ package minecraftgame -import "git.gregbrzezinski.com/Skirda/skirdaGoLauncher/sharedutils/games/skirdagame" +import "git.gregbrzezinski.com/Skirda/sharedutils/games/skirdagame" const gameType = "minecraft" diff --git a/games/steamgame/steamgame.go b/games/steamgame/steamgame.go index df12489..1ee59fa 100644 --- a/games/steamgame/steamgame.go +++ b/games/steamgame/steamgame.go @@ -1,6 +1,6 @@ package steamgame -import "git.gregbrzezinski.com/Skirda/skirdaGoLauncher/sharedutils/games/skirdagame" +import "git.gregbrzezinski.com/Skirda/sharedutils/games/skirdagame" const gameType = "steam" From fc4ba246f180eae5b4f94e5a35fc517792813f15 Mon Sep 17 00:00:00 2001 From: denver Date: Sun, 12 Feb 2023 02:34:22 +0300 Subject: [PATCH 4/4] add shared structures --- games/minecraftgame/structures.go | 94 ++++++++++++++++++++++++++++++- 1 file changed, 91 insertions(+), 3 deletions(-) diff --git a/games/minecraftgame/structures.go b/games/minecraftgame/structures.go index 5b2fbbc..d954b59 100644 --- a/games/minecraftgame/structures.go +++ b/games/minecraftgame/structures.go @@ -1,8 +1,8 @@ package minecraftgame type JavaVersion struct { - Version `json:"version"` - Specifics []struct { + VersionNums `json:"version"` + Specifics []struct { Os string `json:"os"` Arch string `json:"arch"` URL string `json:"URL"` @@ -10,8 +10,96 @@ type JavaVersion struct { } `json:"specifics"` } -type Version struct { +type VersionNums struct { Major string `json:"major"` Minor string `json:"minor"` Patch string `json:"patch"` } + +type Version struct { + AssetIndex AssetIndex `json:"assetIndex"` + Downloads struct { + Client Artifact `json:"client"` + Server Artifact `json:"server"` + Mods struct { + Required []ModArtifact `json:"required"` + } `json:"mods"` + } `json:"downloads"` + ID string `json:"id"` + Libraries []Lib `json:"libraries"` + //ClientLog LogCfg + MainClass string `json:"mainClass"` + GameArgs []Argument + JVMArgs []Argument + Type string `json:"type"` +} + +type AssetIndex struct { + ID string `json:"id"` + TotalSize uint64 `json:"totalSize"` + Artifact +} + +type Argument struct { + Value string `json:"value"` + Rules []Rule `json:"rules"` +} + +type Rule struct { + Action RuleAct `json:"action" mapstructure:"action"` + // OS information. All fields are regexes. + OS struct { + Name string `json:"name" mapstructure:"name"` + Version string `json:"version" mapstructure:"version"` + Arch string `json:"arch" mapstructure:"arch"` + } `json:"os" mapstructure:"os"` + Features struct { + IsDemoUser *bool `json:"is_demo_user" mapstructure:"is_demo_user"` + HasCustomResolution *bool `json:"has_custom_resolution" mapstructure:"has_custom_resolution"` + } `json:"features" mapstructure:"features"` +} + +type RuleAct string + +const ( + ActAllow RuleAct = "allow" + ActDisallow RuleAct = "disallow" +) + +type LibClassifiers struct { + JavaDoc *Artifact `json:"javadoc"` + NativesLinux *Artifact `json:"natives-linux"` + NativesMacOS *Artifact `json:"natives-osx"` + NativesWin *Artifact `json:"natives-windows"` + Sources *Artifact `json:"sources"` +} + +type Lib struct { + Downloads struct { + MainJar *Artifact `json:"artifact"` + LibClassifiers `json:"classifiers"` + } `json:"downloads"` + NativeSuffixes struct { + Linux string `json:"linux"` + MacOS string `json:"osx"` + Windows string `json:"windows"` + } `json:"natives"` + Name string `json:"name"` + Rules []Rule `json:"rules"` + ExtractRules struct { + Exclude []string `json:"exclude"` + } `json:"extract"` +} + +type Artifact struct { + SHA1 string `json:"sha1"` + Size uint64 `json:"size"` + URL string `json:"url"` +} + +type ModArtifact struct { + Artifact + File string + Name string + Version string +}