mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-11 02:50:15 +08:00
Fix internal PluginData deserializing: MutableCollection.patchImpl
This commit is contained in:
parent
e676117744
commit
aca8582bdf
@ -14,7 +14,6 @@ package net.mamoe.mirai.console.data
|
|||||||
*
|
*
|
||||||
* 例:
|
* 例:
|
||||||
* ```
|
* ```
|
||||||
* @ValueName("accounts")
|
|
||||||
* object AccountPluginData : PluginData by ... {
|
* object AccountPluginData : PluginData by ... {
|
||||||
* @ValueName("info")
|
* @ValueName("info")
|
||||||
* val map: Map<String, String> by value("a" to "b")
|
* val map: Map<String, String> by value("a" to "b")
|
||||||
@ -23,7 +22,7 @@ package net.mamoe.mirai.console.data
|
|||||||
*
|
*
|
||||||
* 将被保存为配置 (YAML 作为示例):
|
* 将被保存为配置 (YAML 作为示例):
|
||||||
* ```yaml
|
* ```yaml
|
||||||
* accounts:
|
* AccountPluginData:
|
||||||
* info:
|
* info:
|
||||||
* a: b
|
* a: b
|
||||||
* ```
|
* ```
|
||||||
|
@ -188,7 +188,8 @@ internal fun <K, V> MutableMap<K, V>.patchImpl(_new: Map<K, V>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal fun <C : MutableCollection<E>, E> C.patchImpl(_new: Collection<E>) {
|
internal fun <C : MutableCollection<E>, E> C.patchImpl(_new: Collection<E>) {
|
||||||
this.retainAll(_new)
|
this.clear()
|
||||||
|
this.addAll(_new)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,6 +18,7 @@ import net.mamoe.mirai.console.util.ConsoleExperimentalAPI
|
|||||||
import net.mamoe.mirai.utils.MiraiLogger
|
import net.mamoe.mirai.utils.MiraiLogger
|
||||||
import net.mamoe.mirai.utils.SilentLogger
|
import net.mamoe.mirai.utils.SilentLogger
|
||||||
import net.mamoe.mirai.utils.debug
|
import net.mamoe.mirai.utils.debug
|
||||||
|
import net.mamoe.mirai.utils.warning
|
||||||
import net.mamoe.yamlkt.Yaml
|
import net.mamoe.yamlkt.Yaml
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
@ -36,6 +37,7 @@ internal open class MultiFilePluginDataStorageImpl(
|
|||||||
|
|
||||||
val text = getPluginDataFile(holder, instance).readText()
|
val text = getPluginDataFile(holder, instance).readText()
|
||||||
if (text.isNotBlank()) {
|
if (text.isNotBlank()) {
|
||||||
|
logger.warning { "Deserializing $text" }
|
||||||
Yaml.default.decodeFromString(instance.updaterSerializer, text)
|
Yaml.default.decodeFromString(instance.updaterSerializer, text)
|
||||||
} else {
|
} else {
|
||||||
this.store(holder, instance) // save an initial copy
|
this.store(holder, instance) // save an initial copy
|
||||||
|
Loading…
Reference in New Issue
Block a user