Compare commits
No commits in common. "46bfc92370c6bc6b62efd06c13452b02fe842076" and "6709726709cfe59c8b90d1b31d7392bed15038ba" have entirely different histories.
46bfc92370
...
6709726709
@ -354,61 +354,3 @@ 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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {InstallVanilla, LaunchInstance, GetInstances, InstallQuilt, InstallFabric, CheckUpdate} from '../wailsjs/go/main/InstanceManager.js'
|
import {InstallVanilla, LaunchInstance, GetInstances, InstallFabric, CheckUpdate} from '../wailsjs/go/main/InstanceManager.js'
|
||||||
import {GetVersions} from '../wailsjs/go/main/App.js'
|
import {GetVersions} from '../wailsjs/go/main/App.js'
|
||||||
import {GetFabricVersions} from '../wailsjs/go/main/Fabric.js'
|
import {GetFabricVersions} from '../wailsjs/go/main/Fabric.js'
|
||||||
import {GetQuiltVersions} from '../wailsjs/go/main/Quilt.js'
|
|
||||||
import {onMount} from 'svelte'
|
import {onMount} from 'svelte'
|
||||||
import {loading, addingInstance} from './global'
|
import {loading, addingInstance} from './global'
|
||||||
import {slide} from 'svelte/transition'
|
import {slide} from 'svelte/transition'
|
||||||
@ -15,8 +14,6 @@
|
|||||||
let loader: string = "none"
|
let loader: string = "none"
|
||||||
let fabric_ver: string = ""
|
let fabric_ver: string = ""
|
||||||
let fab_versions: string[] = []
|
let fab_versions: string[] = []
|
||||||
let quilt_ver: string = ""
|
|
||||||
let quilt_versions: string[] = []
|
|
||||||
|
|
||||||
function updateLists(){
|
function updateLists(){
|
||||||
GetVersions().then((result) => {
|
GetVersions().then((result) => {
|
||||||
@ -39,14 +36,6 @@
|
|||||||
})
|
})
|
||||||
fabric_ver = fab_versions[0]
|
fabric_ver = fab_versions[0]
|
||||||
})
|
})
|
||||||
GetQuiltVersions(pack).then((result) => {
|
|
||||||
quilt_versions = []
|
|
||||||
result.forEach((ver) => {
|
|
||||||
quilt_versions.push(ver.Loader.Version)
|
|
||||||
})
|
|
||||||
quilt_ver = quilt_versions[0]
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
@ -75,13 +64,6 @@
|
|||||||
$loading = false
|
$loading = false
|
||||||
updateLists()
|
updateLists()
|
||||||
})
|
})
|
||||||
break
|
|
||||||
case "quilt":
|
|
||||||
InstallQuilt(name, quilt_ver).then(() => {
|
|
||||||
addingInstance = false
|
|
||||||
$loading = false
|
|
||||||
updateLists()
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -129,12 +111,6 @@
|
|||||||
<option value={ver}>{ver}</option>
|
<option value={ver}>{ver}</option>
|
||||||
{/each}
|
{/each}
|
||||||
</select>
|
</select>
|
||||||
{:else if loader == "quilt"}
|
|
||||||
<select id="quilt_ver" bind:value={quilt_ver} name="quilt_ver">Select Quilt Version:
|
|
||||||
{#each quilt_versions as ver}
|
|
||||||
<option value={ver}>{ver}</option>
|
|
||||||
{/each}
|
|
||||||
</select>
|
|
||||||
{/if}
|
{/if}
|
||||||
<br/>
|
<br/>
|
||||||
<button on:click={install}>Install</button>
|
<button on:click={install}>Install</button>
|
||||||
|
@ -12,8 +12,6 @@ export function InstallFabric(arg1:string,arg2:string):Promise<void>;
|
|||||||
|
|
||||||
export function InstallModpack(arg1:main.Modpack,arg2:string):Promise<void>;
|
export function InstallModpack(arg1:main.Modpack,arg2:string):Promise<void>;
|
||||||
|
|
||||||
export function InstallQuilt(arg1:string,arg2:string):Promise<void>;
|
|
||||||
|
|
||||||
export function InstallVanilla(arg1:string,arg2:string):Promise<void>;
|
export function InstallVanilla(arg1:string,arg2:string):Promise<void>;
|
||||||
|
|
||||||
export function LaunchInstance(arg1:string):Promise<void>;
|
export function LaunchInstance(arg1:string):Promise<void>;
|
||||||
|
@ -22,10 +22,6 @@ export function InstallModpack(arg1, arg2) {
|
|||||||
return window['go']['main']['InstanceManager']['InstallModpack'](arg1, arg2);
|
return window['go']['main']['InstanceManager']['InstallModpack'](arg1, arg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function InstallQuilt(arg1, arg2) {
|
|
||||||
return window['go']['main']['InstanceManager']['InstallQuilt'](arg1, arg2);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function InstallVanilla(arg1, arg2) {
|
export function InstallVanilla(arg1, arg2) {
|
||||||
return window['go']['main']['InstanceManager']['InstallVanilla'](arg1, arg2);
|
return window['go']['main']['InstanceManager']['InstallVanilla'](arg1, arg2);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
|
|
||||||
// This file is automatically generated. DO NOT EDIT
|
|
||||||
import {main} from '../models';
|
|
||||||
|
|
||||||
export function GetQuiltVersions(arg1:string):Promise<Array<main.QuiltVersion>>;
|
|
@ -1,7 +0,0 @@
|
|||||||
// @ts-check
|
|
||||||
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
|
|
||||||
// This file is automatically generated. DO NOT EDIT
|
|
||||||
|
|
||||||
export function GetQuiltVersions(arg1) {
|
|
||||||
return window['go']['main']['Quilt']['GetQuiltVersions'](arg1);
|
|
||||||
}
|
|
@ -242,145 +242,6 @@ export namespace main {
|
|||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export class QuiltDefinition {
|
|
||||||
Separator: string;
|
|
||||||
Build: number;
|
|
||||||
Maven: string;
|
|
||||||
Version: string;
|
|
||||||
Stable: boolean;
|
|
||||||
|
|
||||||
static createFrom(source: any = {}) {
|
|
||||||
return new QuiltDefinition(source);
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(source: any = {}) {
|
|
||||||
if ('string' === typeof source) source = JSON.parse(source);
|
|
||||||
this.Separator = source["Separator"];
|
|
||||||
this.Build = source["Build"];
|
|
||||||
this.Maven = source["Maven"];
|
|
||||||
this.Version = source["Version"];
|
|
||||||
this.Stable = source["Stable"];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
export class QuiltLibrary {
|
|
||||||
Name: string;
|
|
||||||
Url: string;
|
|
||||||
Sha1: string;
|
|
||||||
|
|
||||||
static createFrom(source: any = {}) {
|
|
||||||
return new QuiltLibrary(source);
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(source: any = {}) {
|
|
||||||
if ('string' === typeof source) source = JSON.parse(source);
|
|
||||||
this.Name = source["Name"];
|
|
||||||
this.Url = source["Url"];
|
|
||||||
this.Sha1 = source["Sha1"];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
export class QuiltLibraries {
|
|
||||||
Client: QuiltLibrary[];
|
|
||||||
Common: QuiltLibrary[];
|
|
||||||
Server: QuiltLibrary[];
|
|
||||||
|
|
||||||
static createFrom(source: any = {}) {
|
|
||||||
return new QuiltLibraries(source);
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(source: any = {}) {
|
|
||||||
if ('string' === typeof source) source = JSON.parse(source);
|
|
||||||
this.Client = this.convertValues(source["Client"], QuiltLibrary);
|
|
||||||
this.Common = this.convertValues(source["Common"], QuiltLibrary);
|
|
||||||
this.Server = this.convertValues(source["Server"], QuiltLibrary);
|
|
||||||
}
|
|
||||||
|
|
||||||
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
|
||||||
if (!a) {
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
if (a.slice && a.map) {
|
|
||||||
return (a as any[]).map(elem => this.convertValues(elem, classs));
|
|
||||||
} else if ("object" === typeof a) {
|
|
||||||
if (asMap) {
|
|
||||||
for (const key of Object.keys(a)) {
|
|
||||||
a[key] = new classs(a[key]);
|
|
||||||
}
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
return new classs(a);
|
|
||||||
}
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class QuiltMeta {
|
|
||||||
Version: number;
|
|
||||||
Libraries: QuiltLibraries;
|
|
||||||
MainClass: {[key: string]: string};
|
|
||||||
|
|
||||||
static createFrom(source: any = {}) {
|
|
||||||
return new QuiltMeta(source);
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(source: any = {}) {
|
|
||||||
if ('string' === typeof source) source = JSON.parse(source);
|
|
||||||
this.Version = source["Version"];
|
|
||||||
this.Libraries = this.convertValues(source["Libraries"], QuiltLibraries);
|
|
||||||
this.MainClass = source["MainClass"];
|
|
||||||
}
|
|
||||||
|
|
||||||
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
|
||||||
if (!a) {
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
if (a.slice && a.map) {
|
|
||||||
return (a as any[]).map(elem => this.convertValues(elem, classs));
|
|
||||||
} else if ("object" === typeof a) {
|
|
||||||
if (asMap) {
|
|
||||||
for (const key of Object.keys(a)) {
|
|
||||||
a[key] = new classs(a[key]);
|
|
||||||
}
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
return new classs(a);
|
|
||||||
}
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
export class QuiltVersion {
|
|
||||||
Loader: QuiltDefinition;
|
|
||||||
Intermediary: QuiltDefinition;
|
|
||||||
LauncherMeta: QuiltMeta;
|
|
||||||
|
|
||||||
static createFrom(source: any = {}) {
|
|
||||||
return new QuiltVersion(source);
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(source: any = {}) {
|
|
||||||
if ('string' === typeof source) source = JSON.parse(source);
|
|
||||||
this.Loader = this.convertValues(source["Loader"], QuiltDefinition);
|
|
||||||
this.Intermediary = this.convertValues(source["Intermediary"], QuiltDefinition);
|
|
||||||
this.LauncherMeta = this.convertValues(source["LauncherMeta"], QuiltMeta);
|
|
||||||
}
|
|
||||||
|
|
||||||
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
|
||||||
if (!a) {
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
if (a.slice && a.map) {
|
|
||||||
return (a as any[]).map(elem => this.convertValues(elem, classs));
|
|
||||||
} else if ("object" === typeof a) {
|
|
||||||
if (asMap) {
|
|
||||||
for (const key of Object.keys(a)) {
|
|
||||||
a[key] = new classs(a[key]);
|
|
||||||
}
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
return new classs(a);
|
|
||||||
}
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,6 @@ func main() {
|
|||||||
&app.Java,
|
&app.Java,
|
||||||
&app.Modpacks,
|
&app.Modpacks,
|
||||||
&Fabric{},
|
&Fabric{},
|
||||||
&Quilt{},
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1,111 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"crypto/sha1"
|
|
||||||
"encoding/hex"
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"net/http"
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Quilt struct {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
type QuiltDefinition struct {
|
|
||||||
Separator string
|
|
||||||
Build int
|
|
||||||
Maven string
|
|
||||||
Version string
|
|
||||||
Stable bool
|
|
||||||
}
|
|
||||||
|
|
||||||
type QuiltLibrary struct {
|
|
||||||
Name string
|
|
||||||
Url string
|
|
||||||
Sha1 string
|
|
||||||
}
|
|
||||||
|
|
||||||
type QuiltLibraries struct {
|
|
||||||
Client []QuiltLibrary
|
|
||||||
Common []QuiltLibrary
|
|
||||||
Server []QuiltLibrary
|
|
||||||
}
|
|
||||||
|
|
||||||
type QuiltMeta struct {
|
|
||||||
Version int
|
|
||||||
Libraries QuiltLibraries
|
|
||||||
MainClass map[string]string
|
|
||||||
}
|
|
||||||
|
|
||||||
type QuiltVersion struct {
|
|
||||||
Loader QuiltDefinition
|
|
||||||
Intermediary QuiltDefinition
|
|
||||||
LauncherMeta QuiltMeta
|
|
||||||
}
|
|
||||||
|
|
||||||
func (Quilt)GetQuiltVersions(mcVersion string) ([]QuiltVersion, error) {
|
|
||||||
resp, err := http.Get("https://meta.quiltmc.org/v3/versions/loader/"+mcVersion)
|
|
||||||
if err != nil {
|
|
||||||
return []QuiltVersion{}, fmt.Errorf("Unable to pull quilt version manifest: %s\n", err)
|
|
||||||
}
|
|
||||||
defer resp.Body.Close()
|
|
||||||
data, _ := io.ReadAll(resp.Body)
|
|
||||||
versions := []QuiltVersion{}
|
|
||||||
json.Unmarshal(data, &versions)
|
|
||||||
fmt.Printf("Quilt Versions: %s\n", data)
|
|
||||||
return versions, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetQuiltMetadata(mcVersion string, quiltVersion string) (QuiltVersion, error) {
|
|
||||||
versions, err := Quilt{}.GetQuiltVersions(mcVersion)
|
|
||||||
if err != nil {
|
|
||||||
return QuiltVersion{}, fmt.Errorf("unable to download versions manifest: %e\n", err)
|
|
||||||
}
|
|
||||||
for _, version := range versions {
|
|
||||||
if version.Loader.Version == quiltVersion {
|
|
||||||
return version, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return QuiltVersion{}, fmt.Errorf("Unable to find requested version.\n")
|
|
||||||
}
|
|
||||||
|
|
||||||
func InstallQuiltLib(lib QuiltLibrary, libDir string) {
|
|
||||||
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()
|
|
||||||
data, _ := io.ReadAll(f)
|
|
||||||
sha := sha1.Sum(data)
|
|
||||||
if hex.EncodeToString(sha[:20]) == lib.Sha1 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
resp, err := http.Get(lib.Url+path)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf("unable to find library: %s\n", lib.Url+path)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
defer resp.Body.Close()
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
func InstallQuiltLibs(mcVersion string, quiltVersion string, libDir string) {
|
|
||||||
metadata, _ := GetQuiltMetadata(mcVersion, quiltVersion)
|
|
||||||
for _, lib := range metadata.LauncherMeta.Libraries.Client {
|
|
||||||
InstallQuiltLib(lib, libDir)
|
|
||||||
}
|
|
||||||
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.Intermediary.Maven, Sha1: "", Url: "https://maven.fabricmc.net/"}, libDir)
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user