File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Load diff This file was deleted.
Load diff This file was deleted.
Load diff This file was deleted.
Original file line number Diff line number Diff line change 1- import java.net.URI
2- import java.net.http.HttpRequest
3-
41plugins {
52 base
63}
7-
8-
9-
10- tasks {
11- register(" updateVersionsCf" ) {
12- doLast {
13- val token = System .getenv(" CURSEFORGE_TOKEN" ) ? : throw RuntimeException (" missing CurseForge token" )
14- val response = jsonRequest(
15- HttpRequest .newBuilder()
16- .uri(URI (" https://api.curseforge.com/v1/minecraft/version" ))
17- .header(" X-Api-Token" , token)
18- .build()
19- )
20- assert (response.statusCode() == 200 ) { " Invalid status code (${response.statusCode()} )" }
21- val versions = response.body()[" data" ].associate {
22- it[" versionString" ].asText() to it[" gameVersionId" ].asInt()
23- }
24- project.file(" VERSIONS.txt" ).reader().use { reader ->
25- project.file(" VERSIONS_CF.txt" ).writer().use { writer ->
26- reader.useLines { lines ->
27- for (version in lines) {
28- val versionId = versions[version]
29- if (versionId != null ) {
30- writer.write(" $versionId \n " )
31- }
32- }
33- }
34- }
35- }
36- }
37- }
38- }
You can’t perform that action at this time.
0 commit comments