HMCL modpack export

This commit is contained in:
huangyuhui
2017-08-24 13:57:01 +08:00
parent 2e3d9c22e3
commit 6da1dc5372
27 changed files with 648 additions and 150 deletions

View File

@@ -35,7 +35,7 @@ import java.util.concurrent.atomic.AtomicBoolean
* This class is to parse log4j classic XML layout logging, since only vanilla Minecraft will enable this layout.
* Also supports plain logs.
*/
internal class Log4jHandler(val callback: (String, Log4jLevel) -> Unit) : Thread() {
internal class Log4jHandler(private val callback: (String, Log4jLevel) -> Unit) : Thread() {
val reader = XMLReaderFactory.createXMLReader().apply {
contentHandler = Log4jHandlerImpl()
}
@@ -94,10 +94,10 @@ internal class Log4jHandler(val callback: (String, Log4jLevel) -> Unit) : Thread
message = StringBuilder()
val d = Date(attributes.getValue("timestamp").toLong())
date = df.format(d)
try {
l = Log4jLevel.valueOf(attributes.getValue("level"))
l = try {
Log4jLevel.valueOf(attributes.getValue("level"))
} catch (e: IllegalArgumentException) {
l = Log4jLevel.INFO
Log4jLevel.INFO
}
thread = attributes.getValue("thread")

View File

@@ -19,9 +19,9 @@ package org.jackhuang.hmcl.mod
data class Modpack @JvmOverloads constructor(
val name: String = "",
val author: String = "",
val version: String = "",
val gameVersion: String = "",
val description: String = "",
val author: String? = null,
val version: String? = null,
val gameVersion: String? = null,
val description: String? = null,
val manifest: Any? = null
)

View File

@@ -30,6 +30,7 @@ import org.jackhuang.hmcl.launch.ProcessListener
import org.jackhuang.hmcl.util.makeCommand
import org.jackhuang.hmcl.task.Task
import org.jackhuang.hmcl.task.TaskListener
import org.jackhuang.hmcl.util.Log4jLevel
import java.io.File
import java.net.InetSocketAddress
import java.net.Proxy
@@ -53,15 +54,11 @@ class Test {
account = OfflineAccount.fromUsername("player007").logIn(),
options = LaunchOptions(gameDir = repository.baseDirectory),
listener = object : ProcessListener {
override fun onLog(log: String) {
override fun onLog(log: String, level: Log4jLevel) {
println(log)
}
override fun onErrorLog(log: String) {
System.err.println(log)
}
override fun onExit(exitCode: Int) {
override fun onExit(exitCode: Int, exitType: ProcessListener.ExitType) {
println("Process exited then exit code $exitCode")
}