mirror of https://github.com/kami-blue/client
[fix] PacketLogger loading null lines causing a crash
Closes #1601 Signed-off-by: Dominika <sokolov.dominika@gmail.com>
This commit is contained in:
parent
11438ea88d
commit
745eaab4d4
|
@ -24,7 +24,7 @@ object PacketLogger : Module() {
|
|||
|
||||
private const val filename = "KAMIBluePackets.txt"
|
||||
private val lines = ArrayList<String>()
|
||||
private val FORMAT = SimpleDateFormat("HH:mm:ss.SSS")
|
||||
private val sdf = SimpleDateFormat("HH:mm:ss.SSS")
|
||||
|
||||
override fun onEnable() {
|
||||
if (mc.player == null) disable() else if (append.value) readToList()
|
||||
|
@ -41,13 +41,7 @@ object PacketLogger : Module() {
|
|||
return@listener
|
||||
}
|
||||
|
||||
/* see https://kotlinlang.org/docs/reference/basic-types.html#string-templates for usage of $*/
|
||||
lines.add("""
|
||||
${FORMAT.format(Date())}
|
||||
${it.packet.javaClass.simpleName}
|
||||
${it.packet.javaClass}
|
||||
${it.packet}
|
||||
""")
|
||||
lines.add("${sdf.format(Date())} ${it.packet.javaClass.simpleName} ${it.packet.javaClass} ${it.packet}")
|
||||
}
|
||||
|
||||
listener<SafeTickEvent> {
|
||||
|
@ -79,7 +73,10 @@ object PacketLogger : Module() {
|
|||
lines.add(line)
|
||||
}
|
||||
bufferedReader.close()
|
||||
} catch (ignored: IOException) {
|
||||
} catch (ignored: Exception) {
|
||||
// this is fine, just don't load a file
|
||||
KamiMod.log.error("$chatName Error loading!")
|
||||
lines.clear()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue