File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -5,13 +5,19 @@ import net.mamoe.mirai.console.data.*
5
5
object RandOperationHistory : AutoSavePluginData(" RandOperationHistory" ) {
6
6
@ValueName(" history" )
7
7
@ValueDescription(" 随机操作历史记录" )
8
- var history: Map <Long , MutableList <String >> by value(hashMapOf())
8
+ var history: MutableMap <Long , MutableList <String >> by value(hashMapOf())
9
9
10
10
fun addRecord (qq : Long , record : String ) {
11
11
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
+ }
15
21
}
16
22
}
17
23
You can’t perform that action at this time.
0 commit comments