diff --git a/.gitignore b/.gitignore index a112012..4d7571d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ debug/ target/ logs/ +**/logs/ # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries # More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html diff --git a/fclauncher/InstanceManager.go b/fclauncher/InstanceManager.go index 957d0cb..72add3f 100644 --- a/fclauncher/InstanceManager.go +++ b/fclauncher/InstanceManager.go @@ -307,38 +307,14 @@ func (i *InstanceManager)InstallFabric(instance string, fabricVersion string) { fmt.Printf("unable to get version metadata\n") } for _, lib := range metadata.LauncherMeta.Libraries.Client { - tokens := strings.SplitN(lib.Name, ".", 2) - org1 := tokens[0] - tokens = strings.Split(tokens[1], ":") - org2 := tokens[0] - pack := tokens[1] - version := tokens[2] - instanceObject.Libraries = append(instanceObject.Libraries, filepath.Join(org1, org2, pack, version, pack+"-"+version+".jar")) + instanceObject.Libraries = append(instanceObject.Libraries, filepath.Join(ProcessMavenPath(lib.Name), ProcessMavenFilename(lib.Name))) } for _, lib := range metadata.LauncherMeta.Libraries.Common { - tokens := strings.SplitN(lib.Name, ".", 2) - org1 := tokens[0] - tokens = strings.Split(tokens[1], ":") - org2 := tokens[0] - pack := tokens[1] - version := tokens[2] - instanceObject.Libraries = append(instanceObject.Libraries, filepath.Join(org1, org2, pack, version, pack+"-"+version+".jar")) + instanceObject.Libraries = append(instanceObject.Libraries, filepath.Join(ProcessMavenPath(lib.Name), ProcessMavenFilename(lib.Name))) } - tokens := strings.SplitN(metadata.Loader.Maven, ".", 2) - org1 := tokens[0] - tokens = strings.Split(tokens[1], ":") - org2 := tokens[0] - pack := tokens[1] - version := tokens[2] - instanceObject.Libraries = append(instanceObject.Libraries, filepath.Join(org1, org2, pack, version, pack+"-"+version+".jar")) + instanceObject.Libraries = append(instanceObject.Libraries, filepath.Join(ProcessMavenPath(metadata.Loader.Maven), ProcessMavenFilename(metadata.Loader.Maven))) - tokens = strings.SplitN(metadata.Intermediary.Maven, ".", 2) - org1 = tokens[0] - tokens = strings.Split(tokens[1], ":") - org2 = tokens[0] - pack = tokens[1] - version = tokens[2] - instanceObject.Libraries = append(instanceObject.Libraries, filepath.Join(org1, org2, pack, version, pack+"-"+version+".jar")) + instanceObject.Libraries = append(instanceObject.Libraries, filepath.Join(ProcessMavenPath(metadata.Intermediary.Maven), ProcessMavenFilename(metadata.Intermediary.Maven))) instanceObject.MainClass = metadata.LauncherMeta.MainClass["client"] instanceObject.FabricVersion = fabricVersion diff --git a/fclauncher/fabric.go b/fclauncher/fabric.go index a4c553c..bf601fd 100644 --- a/fclauncher/fabric.go +++ b/fclauncher/fabric.go @@ -75,13 +75,7 @@ func GetFabricMetadata(mcVersion string, fabricVersion string) (FabricVersion, e } func InstallLib(lib FabricLibrary, libDir string) { - tokens := strings.SplitN(lib.Name, ".", 2) - org1 := tokens[0] - tokens = strings.Split(tokens[1], ":") - org2 := tokens[0] - pack := tokens[1] - version := tokens[2] - path := filepath.Join(org1, org2, pack, version, pack+"-"+version+".jar") + path := filepath.Join(ProcessMavenPath(lib.Name), ProcessMavenFilename(lib.Name)) if _, err := os.Stat(filepath.Join(libDir, path)); err == nil { f, _ := os.OpenFile(filepath.Join(libDir, path), os.O_RDONLY, 0755) defer f.Close() @@ -96,7 +90,7 @@ func InstallLib(lib FabricLibrary, libDir string) { return } defer resp.Body.Close() - os.MkdirAll(filepath.Join(libDir, org1, org2, pack, version), 0755) + os.MkdirAll(filepath.Join(libDir, ProcessMavenPath(lib.Name)), 0755) f, _ := os.OpenFile(filepath.Join(libDir, path), os.O_CREATE|os.O_RDWR, 0755) defer f.Close() io.Copy(f, resp.Body) @@ -113,3 +107,19 @@ func InstallFabricLibs(mcVersion string, fabricVersion string, libDir string) { InstallLib(FabricLibrary{Name: metadata.Loader.Maven, Sha1: "", Url: "https://maven.fabricmc.net/"}, libDir) InstallLib(FabricLibrary{Name: metadata.Intermediary.Maven, Sha1: "", Url: "https://maven.fabricmc.net/"}, libDir) } + +func ProcessMavenPath(maven string) string { + tokens := strings.Split(maven, ":") + path := filepath.Join(strings.Split(tokens[0], ".")...) + pack := tokens[1] + version := tokens[2] + path = filepath.Join(path, pack, version) + return path +} + +func ProcessMavenFilename(maven string) string { + tokens := strings.Split(maven, ":") + pack := tokens[1] + version := tokens[2] + return pack+"-"+version+".jar" +}