quilt implemented

This commit is contained in:
Samuel Walker 2024-10-31 18:57:54 -06:00
parent 46bfc92370
commit a614f71aa1
5 changed files with 15 additions and 4 deletions

View File

@ -65,7 +65,6 @@ func (i *InstanceManager)SearchInstances() {
io.Copy(buff, f)
instance := Instance{}
json.Unmarshal(buff.Bytes(), &instance)
fmt.Printf("Found Instance: %+v\n", instance)
i.instances = append(i.instances, instance)
}
}
@ -397,6 +396,8 @@ func (i *InstanceManager)InstallQuilt(instance string, quiltVersion string) {
instanceObject.Libraries = append(instanceObject.Libraries, filepath.Join(ProcessMavenPath(metadata.Intermediary.Maven), ProcessMavenFilename(metadata.Intermediary.Maven)))
instanceObject.Libraries = append(instanceObject.Libraries, filepath.Join(ProcessMavenPath(metadata.Hashed.Maven), ProcessMavenFilename(metadata.Hashed.Maven)))
instanceObject.MainClass = metadata.LauncherMeta.MainClass["client"]
instanceObject.QuiltVersion = quiltVersion
dir, _ := os.UserConfigDir()

View File

@ -78,7 +78,7 @@
break
case "quilt":
InstallQuilt(name, quilt_ver).then(() => {
addingInstance = false
$addingInstance = false
$loading = false
updateLists()
})

View File

@ -350,6 +350,7 @@ export namespace main {
export class QuiltVersion {
Loader: QuiltDefinition;
Intermediary: QuiltDefinition;
Hashed: QuiltDefinition;
LauncherMeta: QuiltMeta;
static createFrom(source: any = {}) {
@ -360,6 +361,7 @@ export namespace main {
if ('string' === typeof source) source = JSON.parse(source);
this.Loader = this.convertValues(source["Loader"], QuiltDefinition);
this.Intermediary = this.convertValues(source["Intermediary"], QuiltDefinition);
this.Hashed = this.convertValues(source["Hashed"], QuiltDefinition);
this.LauncherMeta = this.convertValues(source["LauncherMeta"], QuiltMeta);
}

View File

@ -549,6 +549,9 @@ func GetBaseLaunchArgs(mcVersion string, instance Instance, libDir string, binDi
}
for _, lib := range instance.Libraries {
arg += filepath.Join(libDir, lib) + separater
if _, err := os.Stat(filepath.Join(libDir, lib)); err != nil {
fmt.Printf("Error: missing library: %s\n", lib)
}
}
arg += filepath.Join(binDir, mcVersion, "client.jar")
args = append(args, arg)

View File

@ -45,6 +45,7 @@ type QuiltMeta struct {
type QuiltVersion struct {
Loader QuiltDefinition
Intermediary QuiltDefinition
Hashed QuiltDefinition
LauncherMeta QuiltMeta
}
@ -57,7 +58,6 @@ func (Quilt)GetQuiltVersions(mcVersion string) ([]QuiltVersion, error) {
data, _ := io.ReadAll(resp.Body)
versions := []QuiltVersion{}
json.Unmarshal(data, &versions)
fmt.Printf("Quilt Versions: %s\n", data)
return versions, nil
}
@ -91,6 +91,10 @@ func InstallQuiltLib(lib QuiltLibrary, libDir string) {
return
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
fmt.Printf("unable to find library: %s\n", lib.Url+path)
return
}
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()
@ -105,7 +109,8 @@ func InstallQuiltLibs(mcVersion string, quiltVersion string, libDir string) {
for _, lib := range metadata.LauncherMeta.Libraries.Common {
InstallQuiltLib(lib, libDir)
}
InstallQuiltLib(QuiltLibrary{Name: metadata.Loader.Maven, Sha1: "", Url: "https://maven.fabricmc.net/"}, libDir)
InstallQuiltLib(QuiltLibrary{Name: metadata.Loader.Maven, Sha1: "", Url: "https://maven.quiltmc.org/repository/release/"}, libDir)
InstallQuiltLib(QuiltLibrary{Name: metadata.Intermediary.Maven, Sha1: "", Url: "https://maven.fabricmc.net/"}, libDir)
InstallQuiltLib(QuiltLibrary{Name: metadata.Hashed.Maven, Sha1: "", Url: "https://maven.quiltmc.org/repository/release/"}, libDir)
}