@@ -127,7 +127,7 @@ abstract class AbstractPatchRouletteTask : BaseTask() {
127127 fun setPatches (paths : List <String >) {
128128 val response = httpClient().send(
129129 HttpRequest .newBuilder()
130- .POST (HttpRequest .BodyPublishers .ofString(gson.toJson(SetPatches (paths, minecraftVersion.get()))))
130+ .POST (HttpRequest .BodyPublishers .ofString(gson.toJson(SetPatches (paths.normalisePathSeparators() , minecraftVersion.get()))))
131131 .uri(URI .create(endpoint.get() + " /set-patches" ))
132132 .auth()
133133 .contentTypeApplicationJson()
@@ -156,13 +156,13 @@ abstract class AbstractPatchRouletteTask : BaseTask() {
156156 logger.lifecycle(" Cleared patches for ${minecraftVersion.get()} " )
157157 }
158158
159- data class PatchInfo (val path : String , val minecraftVersion : String )
159+ data class PatchesInfo (val paths : List < String > , val minecraftVersion : String )
160160
161- fun startPatch ( path : String ) {
161+ fun startPatches ( paths : List < String >): List < String > {
162162 val response = httpClient().send(
163163 HttpRequest .newBuilder()
164- .POST (HttpRequest .BodyPublishers .ofString(gson.toJson(PatchInfo (path , minecraftVersion.get()))))
165- .uri(URI .create(endpoint.get() + " /start-patch " ))
164+ .POST (HttpRequest .BodyPublishers .ofString(gson.toJson(PatchesInfo (paths.normalisePathSeparators() , minecraftVersion.get()))))
165+ .uri(URI .create(endpoint.get() + " /start-patches " ))
166166 .auth()
167167 .contentTypeApplicationJson()
168168 .build(),
@@ -171,13 +171,17 @@ abstract class AbstractPatchRouletteTask : BaseTask() {
171171 if (response.statusCode() != 200 ) {
172172 throw PaperweightException (" Response status code: ${response.statusCode()} , body: ${response.body()} " )
173173 }
174- logger.lifecycle(" Started patch $path " )
174+ val startedPatches = gson.fromJson<List <String >>(response.body(), typeToken<List <String >>())
175+ logger.lifecycle(" Started patches $startedPatches " )
176+ return startedPatches
175177 }
176178
179+ data class PatchInfo (val path : String , val minecraftVersion : String )
180+
177181 fun completePatch (path : String ) {
178182 val response = httpClient().send(
179183 HttpRequest .newBuilder()
180- .POST (HttpRequest .BodyPublishers .ofString(gson.toJson(PatchInfo (path, minecraftVersion.get()))))
184+ .POST (HttpRequest .BodyPublishers .ofString(gson.toJson(PatchInfo (path.normalisePathSeparators() , minecraftVersion.get()))))
181185 .uri(URI .create(endpoint.get() + " /complete-patch" ))
182186 .auth()
183187 .contentTypeApplicationJson()
@@ -193,7 +197,7 @@ abstract class AbstractPatchRouletteTask : BaseTask() {
193197 fun cancelPatch (path : String ) {
194198 val response = httpClient().send(
195199 HttpRequest .newBuilder()
196- .POST (HttpRequest .BodyPublishers .ofString(gson.toJson(PatchInfo (path, minecraftVersion.get()))))
200+ .POST (HttpRequest .BodyPublishers .ofString(gson.toJson(PatchInfo (path.normalisePathSeparators() , minecraftVersion.get()))))
197201 .uri(URI .create(endpoint.get() + " /cancel-patch" ))
198202 .auth()
199203 .contentTypeApplicationJson()
@@ -206,3 +210,6 @@ abstract class AbstractPatchRouletteTask : BaseTask() {
206210 logger.lifecycle(" Cancelled patch $path " )
207211 }
208212}
213+
214+ private fun String.normalisePathSeparators (): String = replace(" \\ " , " /" )
215+ private fun List<String>.normalisePathSeparators (): List <String > = map { it.replace(" \\ " , " /" ) }
0 commit comments