Add AbstractJvmPlugin.save and AbstractJvmPlugin.savePluginData, close #408 (#420)

This commit is contained in:
Him188 2021-11-26 18:22:22 +00:00 committed by GitHub
parent fe2d8332fe
commit 29f6ece98b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -57,6 +57,24 @@ public abstract class AbstractJvmPlugin @JvmOverloads constructor(
@JvmName("reloadPluginConfig")
public fun <T : PluginConfig> T.reload(): Unit = loader.configStorage.load(this@AbstractJvmPlugin, this)
/**
* 立即保存 [PluginData]
*
* @see reloadPluginData
* @since 2.9
*/
@JvmName("savePluginData")
public fun <T : PluginData> T.save(): Unit = loader.dataStorage.store(this@AbstractJvmPlugin, this)
/**
* 立即保存 [PluginConfig]
*
* @see reloadPluginConfig
* @since 2.9
*/
@JvmName("savePluginConfig")
public fun <T : PluginConfig> T.save(): Unit = loader.configStorage.store(this@AbstractJvmPlugin, this)
@ConsoleExperimentalApi
public override val autoSaveIntervalMillis: LongRange = 30.secondsToMillis..10.minutesToMillis
}
@ -76,3 +94,21 @@ public inline fun AbstractJvmPlugin.reloadPluginData(instance: PluginData): Unit
*/
@JvmSynthetic
public inline fun AbstractJvmPlugin.reloadPluginConfig(instance: PluginConfig): Unit = this.run { instance.reload() }
/**
* 立即保存 [PluginData]
*
* @see AbstractJvmPlugin.save
* @since 2.9
*/
@JvmSynthetic
public inline fun AbstractJvmPlugin.savePluginData(instance: PluginData): Unit = this.run { instance.save() }
/**
* 立即保存 [PluginConfig]
*
* @see AbstractJvmPlugin.save
* @since 2.9
*/
@JvmSynthetic
public inline fun AbstractJvmPlugin.savePluginConfig(instance: PluginConfig): Unit = this.run { instance.save() }