Skip to content

Commit bff28e2

Browse files
Fixed the bug
1 parent b0bd642 commit bff28e2

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/main/kotlin/storage/RandOperationHistory.kt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,19 @@ import net.mamoe.mirai.console.data.*
55
object RandOperationHistory : AutoSavePluginData("RandOperationHistory") {
66
@ValueName("history")
77
@ValueDescription("随机操作历史记录")
8-
var history: Map<Long, MutableList<String>> by value(hashMapOf())
8+
var history: MutableMap<Long, MutableList<String>> by value(hashMapOf())
99

1010
fun addRecord(qq: Long, record: String) {
1111
synchronized(RandOperationHistory) {
12-
val recordList = history[qq] ?: mutableListOf()
13-
recordList.add(record)
14-
history += qq to recordList
12+
history =
13+
if (!history.containsKey(qq)) {
14+
history[qq] = mutableListOf()
15+
history[qq]!!.add(record)
16+
history
17+
} else {
18+
history[qq]!!.add(record)
19+
history
20+
}
1521
}
1622
}
1723

0 commit comments

Comments
 (0)