diff --git a/fclauncher/InstanceManager.go b/fclauncher/InstanceManager.go index eebd2c1..77f3bcd 100644 --- a/fclauncher/InstanceManager.go +++ b/fclauncher/InstanceManager.go @@ -354,3 +354,61 @@ func (i *InstanceManager)InstallFabric(instance string, fabricVersion string) { } } } + +func (i *InstanceManager)InstallQuilt(instance string, quiltVersion string) { + i.app.Status("Installing Quilt") + instanceObject, err := i.GetInstance(instance) + if err != nil { + fmt.Printf("Instance does not exist\n") + } + metadata, err := GetQuiltMetadata(instanceObject.MinecraftVersion, quiltVersion) + if err != nil { + fmt.Printf("unable to get version metadata\n") + } + client: + for _, lib := range metadata.LauncherMeta.Libraries.Client { + tokens := strings.Split(ProcessMavenPath(lib.Name), string(os.PathSeparator)) + pkg := tokens[len(tokens)-2] + instanceObject.Libraries = append(instanceObject.Libraries, filepath.Join(ProcessMavenPath(lib.Name), ProcessMavenFilename(lib.Name))) + for ind, path := range instanceObject.Libraries { + tokens := strings.Split(path, string(os.PathSeparator)) + if pkg == tokens[len(tokens)-3] { + instanceObject.Libraries[ind] = filepath.Join(ProcessMavenPath(lib.Name), ProcessMavenFilename(lib.Name)) + fmt.Printf("duplicate library %s\n", pkg) + continue client + } + } + } + common: + for _, lib := range metadata.LauncherMeta.Libraries.Common { + tokens := strings.Split(ProcessMavenPath(lib.Name), string(os.PathSeparator)) + pkg := tokens[len(tokens)-2] + instanceObject.Libraries = append(instanceObject.Libraries, filepath.Join(ProcessMavenPath(lib.Name), ProcessMavenFilename(lib.Name))) + for ind, path := range instanceObject.Libraries { + tokens := strings.Split(path, string(os.PathSeparator)) + if pkg == tokens[len(tokens)-3] { + instanceObject.Libraries[ind] = filepath.Join(ProcessMavenPath(lib.Name), ProcessMavenFilename(lib.Name)) + fmt.Printf("duplicate library %s\n", pkg) + continue common + } + } + } + instanceObject.Libraries = append(instanceObject.Libraries, filepath.Join(ProcessMavenPath(metadata.Loader.Maven), ProcessMavenFilename(metadata.Loader.Maven))) + + instanceObject.Libraries = append(instanceObject.Libraries, filepath.Join(ProcessMavenPath(metadata.Intermediary.Maven), ProcessMavenFilename(metadata.Intermediary.Maven))) + + instanceObject.MainClass = metadata.LauncherMeta.MainClass["client"] + instanceObject.QuiltVersion = quiltVersion + dir, _ := os.UserConfigDir() + InstallQuiltLibs(instanceObject.MinecraftVersion, quiltVersion, filepath.Join(dir, "FCLauncher", "lib")) + f, _ := os.OpenFile(filepath.Join(dir, "FCLauncher", "instances", instance, "instance.json"), os.O_CREATE|os.O_RDWR, 0755) + data, _ := json.Marshal(instanceObject) + defer f.Close() + f.Write(data) + for ind, inst := range i.instances { + if inst.InstanceName == instance { + i.instances[ind] = instanceObject + break + } + } +} diff --git a/fclauncher/frontend/src/Instances.svelte b/fclauncher/frontend/src/Instances.svelte index 12043b6..25f9f0a 100644 --- a/fclauncher/frontend/src/Instances.svelte +++ b/fclauncher/frontend/src/Instances.svelte @@ -1,7 +1,8 @@