Skip to content

Commit 63b028a

Browse files
committed
move PatchSelectionStrategy factory method
1 parent 20216c1 commit 63b028a

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

paperweight-core/src/main/kotlin/io/papermc/paperweight/core/tasks/patchroulette/PatchRouletteApply.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ abstract class PatchRouletteApply : AbstractPatchRouletteTask() {
8989
var tries = 5
9090
var patches = listOf<Path>()
9191
val patchSelectionStrategy = patchSelectionStrategy
92-
.map { parsePatchSelectionStrategy(it) }
92+
.map { PatchSelectionStrategy.parse(it) }
9393
.getOrElse(PatchSelectionStrategy.NumericInPackage(5))
9494
while (tries > 0) {
9595
val available = getAvailablePatches().map { Path(it) }.toMutableSet()
@@ -178,13 +178,15 @@ abstract class PatchRouletteApply : AbstractPatchRouletteTask() {
178178
}
179179

180180
fun select(config: Config, available: List<Path>): Pair<Config, List<Path>>
181-
}
182181

183-
private fun parsePatchSelectionStrategy(input: String): PatchSelectionStrategy {
184-
try {
185-
return PatchSelectionStrategy.NumericInPackage(input.toInt())
186-
} catch (e: Exception) {
187-
throw PaperweightException("Failed to parse patch selection strategy $input", e)
182+
companion object {
183+
fun parse(input: String): PatchSelectionStrategy {
184+
try {
185+
return NumericInPackage(input.toInt())
186+
} catch (e: Exception) {
187+
throw PaperweightException("Failed to parse patch selection strategy $input", e)
188+
}
189+
}
188190
}
189191
}
190192
}

0 commit comments

Comments
 (0)