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

@@ -145,3 +145,16 @@ func ComponentToFriendlyName(component string) string {
return component
}
}
// HighestSliceIndex returns the highest index of the given values in the slice (-1 if no value is found in the slice)
func HighestSliceIndex(slice []string, values []string) int {
highest := -1
for _, val := range values {
for i, v := range slice {
if v == val && i > highest {
highest = i
}
}
}
return highest
}