Skip to content

Commit

Permalink
fix curseforge using major version for filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
DeDiamondPro committed Dec 8, 2024
1 parent 609bc3a commit 1fe816c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

- When possible, links to modrinth in a project description will now be opened in Resourcify.
- Add support for side mouse buttons to go back and forward between pages.
- Fix CurseForge version filter using major version instead of exact version.
- You can now select multiple Minecraft versions when using the CurseForge source.

----------------------------------------------------------------------------------------------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ package dev.dediamondpro.resourcify.services.curseforge
import com.google.gson.annotations.SerializedName

data class CurseForgeMinecraftVersions(
@SerializedName("versionString") val name: String,
@SerializedName("gameVersionTypeId") val id: Int
@SerializedName("versionString") val name: String
)

data class CurseForgeMinecraftVersionsResponse(val data: List<CurseForgeMinecraftVersions>)
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ object CurseForgeService : IService {
actualCategories.add("5193") // Add data pack category
}
addParameter("categoryIds", "[${actualCategories.joinToString(",")}]")
if (minecraftVersions.isNotEmpty()) {
addParameter("gameVersionTypeId", minecraftVersions.first().split("+")[0])
}
addParameter("gameVersions", "[${minecraftVersions.joinToString(",") { "\"$it\"" }}]")
}.build().toURL().getJson<CurseForgeSearchData>(headers = mapOf("x-api-key" to API_KEY)).apply {
this?.let { // Filter data packs out of resource packs
if (type != ProjectType.RESOURCE_PACK) return@let
Expand All @@ -83,8 +81,7 @@ object CurseForgeService : IService {
override fun getMinecraftVersions(): CompletableFuture<Map<String, String>> {
fetchMinecraftVersions()
return minecraftVersions?.thenApply {
// Add the name to the id because the id is not unique
it.associate { version -> "${version.id}+${version.name}" to version.name }
it.associate { version -> version.name to version.name }
} ?: supply { emptyMap() }
}

Expand All @@ -99,8 +96,6 @@ object CurseForgeService : IService {
}
}

override fun canSelectMultipleMinecraftVersions(): Boolean = false

override fun getCategories(type: ProjectType): CompletableFuture<Map<String, Map<String, String>>> {
fetchCategories()
return categories?.thenApply {
Expand Down

0 comments on commit 1fe816c

Please sign in to comment.