mirror of
https://github.com/packwiz/packwiz.git
synced 2025-10-17 00:04:31 +02:00
Latest version fixes: correctly order preferences (fixes #198)
Both CurseForge and Modrinth preferences were not being done in a specific order - so a file with a newer Minecraft version would not necessarily take priority over a file with a more preferred loader (e.g. Quilt over Fabric) or a file with a newer release date / CurseForge ID. Also fixed a loop variable reference in the CurseForge loop, which caused eagerly resolved (included in API response) file info to be inconsistent with the chosen version, and added filtering for duplicate values in the acceptable-game-versions/primary version list to ensure game versions are always compared properly (so the same index == same version).
This commit is contained in:
12
core/pack.go
12
core/pack.go
@@ -3,6 +3,7 @@ package core
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"golang.org/x/exp/slices"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -171,7 +172,16 @@ func (pack Pack) GetSupportedMCVersions() ([]string, error) {
|
||||
return nil, errors.New("no minecraft version specified in modpack")
|
||||
}
|
||||
allVersions := append(append([]string(nil), viper.GetStringSlice("acceptable-game-versions")...), mcVersion)
|
||||
return allVersions, nil
|
||||
// Deduplicate values
|
||||
allVersionsDeduped := []string(nil)
|
||||
for i, v := range allVersions {
|
||||
// If another copy of this value exists past this point in the array, don't insert
|
||||
// (i.e. prefer a later copy over an earlier copy, so the main version is last)
|
||||
if !slices.Contains(allVersions[i+1:], v) {
|
||||
allVersionsDeduped = append(allVersionsDeduped, v)
|
||||
}
|
||||
}
|
||||
return allVersionsDeduped, nil
|
||||
}
|
||||
|
||||
func (pack Pack) GetPackName() string {
|
||||
|
Reference in New Issue
Block a user