mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2024-12-27 07:10:41 +08:00
Merge 'arguments'
This commit is contained in:
parent
b81b38f7e4
commit
d2529cfc23
@ -20,6 +20,7 @@ package org.jackhuang.hmcl.game
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import org.jackhuang.hmcl.util.OS
|
||||
import org.jackhuang.hmcl.game.CompatibilityRule.*
|
||||
import org.jackhuang.hmcl.util.merge
|
||||
|
||||
class Arguments @JvmOverloads constructor(
|
||||
@SerializedName("game")
|
||||
@ -28,6 +29,16 @@ class Arguments @JvmOverloads constructor(
|
||||
val jvm: List<Argument>? = null
|
||||
) {
|
||||
companion object {
|
||||
fun mergeArguments(a: Arguments?, b: Arguments?): Arguments? {
|
||||
if (a == null && b == null) return null
|
||||
else if (a == null) return b
|
||||
else if (b == null) return a
|
||||
else return Arguments(
|
||||
game = merge(a.game, b.game),
|
||||
jvm = merge(a.jvm, b.jvm)
|
||||
)
|
||||
}
|
||||
|
||||
fun parseStringArguments(arguments: List<String>, keys: Map<String, String>, features: Map<String, Boolean> = emptyMap()): List<String> {
|
||||
return arguments.flatMap { StringArgument(it).toString(keys, features) }
|
||||
}
|
||||
|
@ -131,6 +131,7 @@ open class Version(
|
||||
libraries = merge(this.libraries, parent.libraries),
|
||||
downloads = this.downloads ?: parent.downloads,
|
||||
assetIndex = this.assetIndex ?: parent.assetIndex,
|
||||
arguments = Arguments.mergeArguments(parent.arguments, this.arguments),
|
||||
releaseTime = this.releaseTime,
|
||||
inheritsFrom = null,
|
||||
minecraftArguments = this.minecraftArguments ?: parent.minecraftArguments,
|
||||
|
@ -32,11 +32,10 @@ import org.jackhuang.hmcl.util.guessLogLineError
|
||||
internal class ExitWaiter(val process: ManagedProcess, val joins: Collection<Thread>, val watcher: (Int, ProcessListener.ExitType) -> Unit) : Runnable {
|
||||
override fun run() {
|
||||
try {
|
||||
process.process.waitFor()
|
||||
val exitCode = process.process.waitFor()
|
||||
|
||||
joins.forEach { it.join() }
|
||||
|
||||
val exitCode = process.exitCode
|
||||
val errorLines = process.lines.filter(::guessLogLineError)
|
||||
val exitType: ProcessListener.ExitType
|
||||
// LaunchWrapper will catch the exception logged and will exit normally.
|
||||
|
@ -50,8 +50,9 @@ fun <T> copyList(list: List<T>?): MutableList<T>? =
|
||||
if (list == null) null
|
||||
else LinkedList(list)
|
||||
|
||||
fun <T> merge(vararg c: Collection<T>): List<T> = LinkedList<T>().apply {
|
||||
fun <T> merge(vararg c: Collection<T>?): List<T> = LinkedList<T>().apply {
|
||||
for (a in c)
|
||||
if (a != null)
|
||||
addAll(a)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user