Improve error messages when unable to find a CF file/addon

This commit is contained in:
comp500
2022-04-23 20:09:10 +01:00
parent f1eb34d444
commit e29c3022b3
2 changed files with 15 additions and 2 deletions

View File

@@ -334,12 +334,14 @@ func searchCurseforgeInternal(args []string, mcVersion string, packLoaderType in
}
func getLatestFile(modInfoData modInfo, mcVersion string, fileID int, packLoaderType int) (modFileInfo, error) {
anyFileObtained := false
// For snapshots, curseforge doesn't put them in GameVersionLatestFiles
if fileID == 0 {
var fileInfoData modFileInfo
fileInfoObtained := false
for _, v := range modInfoData.LatestFiles {
anyFileObtained = true
// Choose "newest" version by largest ID
if matchGameVersions(mcVersion, v.GameVersions) && v.ID > fileID && matchLoaderTypeFileInfo(packLoaderType, v) {
fileID = v.ID
@@ -349,6 +351,7 @@ func getLatestFile(modInfoData modInfo, mcVersion string, fileID int, packLoader
}
// TODO: change to timestamp-based comparison??
for _, v := range modInfoData.GameVersionLatestFiles {
anyFileObtained = true
// Choose "newest" version by largest ID
if matchGameVersion(mcVersion, v.GameVersion) && v.ID > fileID && matchLoaderType(packLoaderType, v.Modloader) {
fileID = v.ID
@@ -360,6 +363,10 @@ func getLatestFile(modInfoData modInfo, mcVersion string, fileID int, packLoader
}
}
if !anyFileObtained {
return modFileInfo{}, fmt.Errorf("addon %d has no files", modInfoData.ID)
}
if fileID == 0 {
return modFileInfo{}, errors.New("mod not available for the configured Minecraft version(s) (use the acceptable-game-versions option to accept more) or loader")
}