Skip to content

Commit

Permalink
maven version lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
nothub committed Oct 10, 2024
1 parent dde4f77 commit 4d52037
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
19 changes: 13 additions & 6 deletions server/neoforge.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package server

import (
"fmt"
"github.com/nothub/mrpack-install/maven"
"github.com/nothub/mrpack-install/web"
"log"
)
Expand All @@ -11,18 +12,24 @@ type NeoForgeInstaller struct {
NeoForgeVersion string
}

// TODO maven version lookup: https://maven.neoforged.net/releases/net/neoforged/forge/maven-metadata.xml

func (inst *NeoForgeInstaller) Install(serverDir string, serverFile string) error {
// TODO: implement automatic lookup for latest version
if inst.NeoForgeVersion == "" || inst.NeoForgeVersion == "latest" {
log.Fatalln("automatic NeoForge version lookup not implemented\nplease set server version with --flavor-version flag")
version := inst.NeoForgeVersion
if version == "" || version == "latest" {
meta, err := maven.FetchMetadata("https://maven.neoforged.net/releases/net/neoforged/neoforge/maven-metadata.xml")
if err != nil {
return err
}
// TODO: instead of using the latest release, match against the latest
// non-pre-release version that matches the minecraft version
version = meta.Versioning.Release
}
u := fmt.Sprintf("https://maven.neoforged.net/releases/net/neoforged/neoforge/%s/neoforge-%s-installer.jar", inst.NeoForgeVersion, inst.NeoForgeVersion)

u := fmt.Sprintf("https://maven.neoforged.net/releases/net/neoforged/neoforge/%s/neoforge-%s-installer.jar", version, version)
file, err := web.DefaultClient.DownloadFile(u, serverDir, serverFile)
if err != nil {
return err
}

log.Println("Server jar downloaded to:", file)
return nil
}
2 changes: 1 addition & 1 deletion web/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (c *Client) DownloadFile(url string, downloadDir string, fileName string) (

// TODO: this needs to (silently?) overwrite existing files!

log.Printf("downloading: %s", url)
log.Printf("Downloading file from: %s", url)

request, err := http.NewRequest(http.MethodGet, url, nil)
if err != nil {
Expand Down

0 comments on commit 4d52037

Please sign in to comment.