diff --git a/fclauncher/app.go b/fclauncher/app.go
index ee8d3f1..9a147ae 100644
--- a/fclauncher/app.go
+++ b/fclauncher/app.go
@@ -11,20 +11,18 @@ import (
"github.com/wailsapp/wails/v2/pkg/runtime"
)
-
const client_id string = "9305aeb8-5ecb-4e7a-b28f-c33aefcfbd8d"
// App struct
type App struct {
- Ctx context.Context
+ Ctx context.Context
PrismLauncher Prism
- Java JavaManager
- Instance InstanceManager
- Modpacks ModpackManager
- Auth authenticationResp
+ Java JavaManager
+ Instance InstanceManager
+ Modpacks ModpackManager
+ Auth authenticationResp
}
-
// NewApp creates a new App application struct
func NewApp() *App {
a := &App{}
@@ -42,16 +40,15 @@ func (a *App) startup(ctx context.Context) {
// Greet returns a greeting for the given name
-
func (a *App) CheckPrerequisites() {
a.Status("Querrying Existing Instances")
a.Instance.SearchInstances()
a.Status("Pulling Modpacks")
a.Modpacks.QuerryModpacks()
a.Status("Logging in with Microsoft")
- dir, _ := os.UserConfigDir()
+ dir, _ := os.UserConfigDir()
authenticated := false
- if _, err := os.Stat(filepath.Join(dir, "FCLauncher", "authentication.json")); err == nil {
+ if _, err := os.Stat(filepath.Join(dir, "FCLauncher", "authentication.json")); err == nil {
f, _ := os.OpenFile(filepath.Join(dir, "FCLauncher", "authentication.json"), os.O_RDONLY, 0755)
defer f.Close()
data, _ := io.ReadAll(f)
diff --git a/fclauncher/forge.go b/fclauncher/forge.go
new file mode 100644
index 0000000..7e6cfc6
--- /dev/null
+++ b/fclauncher/forge.go
@@ -0,0 +1,70 @@
+package main
+
+import (
+ "fmt"
+ "io"
+ "net/http"
+ "strings"
+)
+
+type Forge struct{}
+
+type ForgeVersion struct {
+ Version string
+ Time string
+ Url string
+}
+
+func parseForgeVersions(html string) []ForgeVersion {
+ lines := strings.Split(html, "\n")
+ parsing := false
+ foundTR := false
+ buff := ""
+ versions := []ForgeVersion{}
+ for _, line := range lines {
+ if strings.Contains(line, "
") {
+ parsing = true
+ } else if strings.Contains(line, "") {
+ parsing = false
+ } else if parsing {
+ if strings.Contains(line, "") {
+ buff = ""
+ foundTR = true
+ } else if strings.Contains(line, "
") {
+ foundTR = false
+ versions = append(versions, parseForgeVersion(buff))
+ } else if foundTR {
+ buff += line + "\n"
+ }
+ }
+ }
+ return versions
+}
+
+func parseForgeVersion(html string) ForgeVersion {
+ lines := strings.Split(html, "\n")
+ version := ForgeVersion{}
+ for ind, line := range lines {
+ if strings.Contains(line, "") {
+ version.Version = strings.TrimSpace(lines[ind+1])
+ } else if strings.Contains(line, " | ")[0]
+ } else if strings.Contains(line, "https://adfoc.us") && strings.Contains(line, "installer.jar") {
+ version.Url = strings.Split(strings.Split(line, "&url=")[1], "\">")[0]
+ }
+ }
+ return version
+}
+
+func (Forge) GetForgeVersions(mcVersion string) ([]ForgeVersion, error) {
+ resp, err := http.Get(fmt.Sprintf("https://files.minecraftforge.net/net/minecraftforge/forge/index_%s.html", mcVersion))
+ if err != nil {
+ return []ForgeVersion{}, fmt.Errorf("unable to access minecraft forge index: %e", err)
+ }
+ defer resp.Body.Close()
+ if resp.StatusCode != 200 {
+ return []ForgeVersion{}, fmt.Errorf("unable to access minecraft forge index: %s", err)
+ }
+ data, _ := io.ReadAll(resp.Body)
+ return parseForgeVersions(string(data)), nil
+}
diff --git a/fclauncher/frontend/src/Instances.svelte b/fclauncher/frontend/src/Instances.svelte
index ac2812f..01f815d 100644
--- a/fclauncher/frontend/src/Instances.svelte
+++ b/fclauncher/frontend/src/Instances.svelte
@@ -3,6 +3,7 @@
import {GetVersions} from '../wailsjs/go/main/App.js'
import {GetFabricVersions} from '../wailsjs/go/main/Fabric.js'
import {GetQuiltVersions} from '../wailsjs/go/main/Quilt.js'
+ import {GetForgeVersions} from '../wailsjs/go/main/Forge.js'
import {onMount} from 'svelte'
import {loading, addingInstance} from './global'
import {slide} from 'svelte/transition'
@@ -17,6 +18,8 @@
let fab_versions: string[] = []
let quilt_ver: string = ""
let quilt_versions: string[] = []
+ let forge_ver: string = ""
+ let forge_versions: string[] = []
function updateLists(){
GetVersions().then((result) => {
@@ -46,6 +49,14 @@
})
quilt_ver = quilt_versions[0]
})
+ GetForgeVersions(pack).then((result) => {
+ forge_versions = []
+ result.forEach((ver) => {
+ forge_versions.push(ver.Version)
+ })
+ forge_ver = forge_versions[0]
+ }).catch(() => { forge_versions = []; forge_ver = "" })
+
}
@@ -135,6 +146,12 @@
{/each}
+ {:else if loader == "forge"}
+
{/if}
diff --git a/fclauncher/frontend/wailsjs/go/main/Forge.d.ts b/fclauncher/frontend/wailsjs/go/main/Forge.d.ts
new file mode 100755
index 0000000..31e79b1
--- /dev/null
+++ b/fclauncher/frontend/wailsjs/go/main/Forge.d.ts
@@ -0,0 +1,5 @@
+// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
+// This file is automatically generated. DO NOT EDIT
+import {main} from '../models';
+
+export function GetForgeVersions(arg1:string):Promise>;
diff --git a/fclauncher/frontend/wailsjs/go/main/Forge.js b/fclauncher/frontend/wailsjs/go/main/Forge.js
new file mode 100755
index 0000000..f8b8f55
--- /dev/null
+++ b/fclauncher/frontend/wailsjs/go/main/Forge.js
@@ -0,0 +1,7 @@
+// @ts-check
+// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
+// This file is automatically generated. DO NOT EDIT
+
+export function GetForgeVersions(arg1) {
+ return window['go']['main']['Forge']['GetForgeVersions'](arg1);
+}
diff --git a/fclauncher/frontend/wailsjs/go/models.ts b/fclauncher/frontend/wailsjs/go/models.ts
index b966a54..985b0d9 100755
--- a/fclauncher/frontend/wailsjs/go/models.ts
+++ b/fclauncher/frontend/wailsjs/go/models.ts
@@ -139,6 +139,22 @@ export namespace main {
return a;
}
}
+ export class ForgeVersion {
+ Version: string;
+ Time: string;
+ Url: string;
+
+ static createFrom(source: any = {}) {
+ return new ForgeVersion(source);
+ }
+
+ constructor(source: any = {}) {
+ if ('string' === typeof source) source = JSON.parse(source);
+ this.Version = source["Version"];
+ this.Time = source["Time"];
+ this.Url = source["Url"];
+ }
+ }
export class Instance {
InstanceName: string;
ModpackId: string;
diff --git a/fclauncher/main.go b/fclauncher/main.go
index 361bd0f..f5ef750 100644
--- a/fclauncher/main.go
+++ b/fclauncher/main.go
@@ -33,6 +33,7 @@ func main() {
&app.Modpacks,
&Fabric{},
&Quilt{},
+ &Forge{},
},
})
|