Prefer game versions according to acceptable versions list (fixes #181)

The acceptable versions list should now be specified in order of preference, where the last version is the most preferable Minecraft version
This commit is contained in:
comp500
2023-02-14 16:10:06 +00:00
parent d667447a88
commit d38d279d98
9 changed files with 123 additions and 145 deletions

View File

@@ -164,6 +164,16 @@ func (pack Pack) GetMCVersion() (string, error) {
return mcVersion, nil
}
// GetSupportedMCVersions gets the versions of Minecraft this pack allows in downloaded mods, ordered by preference (highest = most desirable)
func (pack Pack) GetSupportedMCVersions() ([]string, error) {
mcVersion, ok := pack.Versions["minecraft"]
if !ok {
return nil, errors.New("no minecraft version specified in modpack")
}
allVersions := append(append([]string(nil), viper.GetStringSlice("acceptable-game-versions")...), mcVersion)
return allVersions, nil
}
func (pack Pack) GetPackName() string {
if pack.Name == "" {
return "export"