mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-10 02:20:14 +08:00
Add PluginConfig
This commit is contained in:
parent
202e1f0ec9
commit
111788fd04
@ -16,6 +16,7 @@
|
|||||||
[`PluginData`]: ../backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/PluginData.kt
|
[`PluginData`]: ../backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/PluginData.kt
|
||||||
[`AbstractPluginData`]: ../backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/AbstractPluginData.kt
|
[`AbstractPluginData`]: ../backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/AbstractPluginData.kt
|
||||||
[`AutoSavePluginData`]: ../backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/AutoSavePluginData.kt
|
[`AutoSavePluginData`]: ../backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/AutoSavePluginData.kt
|
||||||
|
[`AutoSavePluginConfig`]: ../backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/AutoSavePluginConfig.kt
|
||||||
[`PluginConfig`]: ../backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/PluginConfig.kt
|
[`PluginConfig`]: ../backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/PluginConfig.kt
|
||||||
[`PluginDataStorage`]: ../backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/PluginDataStorage.kt
|
[`PluginDataStorage`]: ../backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/PluginDataStorage.kt
|
||||||
[`MultiFilePluginDataStorage`]: ../backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/PluginDataStorage.kt#L116
|
[`MultiFilePluginDataStorage`]: ../backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/PluginDataStorage.kt#L116
|
||||||
@ -211,12 +212,26 @@ val value by value<MutableMap<Long, List<Int>>>().withEmptyDefault().mapKeys(Bot
|
|||||||
```
|
```
|
||||||
使用时:
|
使用时:
|
||||||
```kotlin
|
```kotlin
|
||||||
val bot: Bot = TODO()
|
val bot: Bot = getBot()
|
||||||
|
|
||||||
val list: List<Int> = value[bot]
|
val list: List<Int> = value[bot]
|
||||||
value[bot] = listOf()
|
value[bot] = listOf()
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## [`PluginConfig`]
|
||||||
|
|
||||||
|
### [`PluginData`] 与 [`PluginConfig`] 的区别
|
||||||
|
- [`PluginData`] 表示插件内部的数据,不应该被用户看到。
|
||||||
|
- [`PluginConfig`] 表示插件的配置,用户可以修改这些配置。
|
||||||
|
|
||||||
|
### 使用 [`PluginConfig`]
|
||||||
|
[`PluginConfig`] 与 [`PluginData`] 用法完全相同。
|
||||||
|
|
||||||
|
在上述 [使用 `PluginData`](#使用-plugindata) 的示例中,
|
||||||
|
将 [`AutoSavePluginData`] 换为 [`AutoSavePluginConfig`] 即可创建一个配置,而不是数据。
|
||||||
|
|
||||||
|
在加载时使用 `configInstance.reload()` 或 `JvmPlugin.reloadPluginConfig(configInstance)`。
|
||||||
|
|
||||||
## [`PluginDataHolder`]
|
## [`PluginDataHolder`]
|
||||||
***注意:这是实验性 API。***
|
***注意:这是实验性 API。***
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user