Use FlexVer to get largest loader version (fixes Forge default version in init)

This commit is contained in:
comp500 2022-11-19 20:25:38 +00:00
parent 4f6528dcb5
commit 6160c2ac01
3 changed files with 7 additions and 1 deletions

View File

@ -3,6 +3,7 @@ package core
import (
"encoding/xml"
"errors"
"github.com/unascribed/FlexVer/go/flexver"
"strings"
)
@ -93,6 +94,8 @@ func FetchMavenVersionPrefixedList(url string, friendlyName string) func(mcVersi
if hasPrefixSplitDash(out.Versioning.Latest, mcVersion) {
return allowedVersions, out.Versioning.Latest, nil
}
// Sort list to get largest version
flexver.VersionSlice(out.Versioning.Versions.Version).Sort()
return allowedVersions, allowedVersions[len(allowedVersions)-1], nil
}
}

3
go.mod
View File

@ -29,6 +29,7 @@ require (
require (
codeberg.org/jmansfield/go-modrinth v0.4.1
github.com/spf13/pflag v1.0.5
github.com/unascribed/FlexVer/go/flexver v1.0.0
golang.org/x/exp v0.0.0-20220414153411-bcd21879b8fd
)
@ -50,4 +51,4 @@ require (
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)
go 1.18
go 1.19

2
go.sum
View File

@ -205,6 +205,8 @@ github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMT
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/unascribed/FlexVer/go/flexver v1.0.0 h1:eaAAWwaT8TiGK75wfEgQRPRVJc1ZIiLTLGUKXxpcs0c=
github.com/unascribed/FlexVer/go/flexver v1.0.0/go.mod h1:OkWZGfmV3DV2ADlgoS7W1+dD1OOci4mEracZCi3ulBk=
github.com/vbauerster/mpb/v4 v4.12.2 h1:TsBs1nWRYF0m8cUH13pxNhOUqY6yKcOr2PeSYxp2L3I=
github.com/vbauerster/mpb/v4 v4.12.2/go.mod h1:LVRGvMch8T4HQO3eg2pFPsACH9kO/O6fT/7vhGje3QE=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=