From 1186083f09c25e6c25cf1da6edd4e4c8acadffb6 Mon Sep 17 00:00:00 2001 From: Him188 Date: Wed, 24 Jun 2020 04:31:24 +0800 Subject: [PATCH] Introduce AbstractJvmPlugin --- .../console/plugin/jvm/AbstractJvmPlugin.kt | 28 +++++++++++++++++++ .../mirai/console/plugin/jvm/JavaPlugin.kt | 3 +- .../mirai/console/plugin/jvm/JvmPlugin.kt | 4 ++- .../mirai/console/plugin/jvm/KotlinPlugin.kt | 3 +- 4 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/AbstractJvmPlugin.kt diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/AbstractJvmPlugin.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/AbstractJvmPlugin.kt new file mode 100644 index 000000000..6bef6b96c --- /dev/null +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/AbstractJvmPlugin.kt @@ -0,0 +1,28 @@ +/* + * Copyright 2020 Mamoe Technologies and contributors. + * + * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. + * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. + * + * https://github.com/mamoe/mirai/blob/master/LICENSE + */ + +@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE", "EXPOSED_SUPER_CLASS") + +package net.mamoe.mirai.console.plugin.jvm + +import net.mamoe.mirai.console.plugin.internal.JvmPluginImpl +import kotlin.coroutines.CoroutineContext +import kotlin.coroutines.EmptyCoroutineContext + +/** + * [JavaPlugin] 和 [KotlinPlugin] 的父类 + * + * @see JavaPlugin + * @see KotlinPlugin + */ +abstract class AbstractJvmPlugin @JvmOverloads constructor( + parentCoroutineContext: CoroutineContext = EmptyCoroutineContext +) : JvmPlugin, JvmPluginImpl(parentCoroutineContext) { + // TODO: 2020/6/24 添加 PluginSetting 继承 Setting, 实现 onValueChanged 并绑定自动保存. +} \ No newline at end of file diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/JavaPlugin.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/JavaPlugin.kt index 4f245939e..6e3311d64 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/JavaPlugin.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/JavaPlugin.kt @@ -11,7 +11,6 @@ package net.mamoe.mirai.console.plugin.jvm -import net.mamoe.mirai.console.plugin.internal.JvmPluginImpl import net.mamoe.mirai.console.utils.JavaPluginScheduler import kotlin.coroutines.CoroutineContext import kotlin.coroutines.EmptyCoroutineContext @@ -21,7 +20,7 @@ import kotlin.coroutines.EmptyCoroutineContext */ abstract class JavaPlugin @JvmOverloads constructor( parentCoroutineContext: CoroutineContext = EmptyCoroutineContext -) : JvmPlugin, JvmPluginImpl(parentCoroutineContext) { +) : JvmPlugin, AbstractJvmPlugin(parentCoroutineContext) { /** * Java API Scheduler diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/JvmPlugin.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/JvmPlugin.kt index 4321c8255..243300905 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/JvmPlugin.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/JvmPlugin.kt @@ -17,7 +17,9 @@ import net.mamoe.mirai.utils.MiraiLogger /** - * Java 或 Kotlin Jar 插件 + * Java, Kotlin 或其他 JVM 平台插件 + * + * @see AbstractJvmPlugin 默认实现 * * @see JavaPlugin Java 插件 * @see KotlinPlugin Kotlin 插件 diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/KotlinPlugin.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/KotlinPlugin.kt index e3a9dc28f..f9ceee8f9 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/KotlinPlugin.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/KotlinPlugin.kt @@ -11,7 +11,6 @@ package net.mamoe.mirai.console.plugin.jvm -import net.mamoe.mirai.console.plugin.internal.JvmPluginImpl import kotlin.coroutines.CoroutineContext import kotlin.coroutines.EmptyCoroutineContext @@ -20,4 +19,4 @@ import kotlin.coroutines.EmptyCoroutineContext */ abstract class KotlinPlugin @JvmOverloads constructor( parentCoroutineContext: CoroutineContext = EmptyCoroutineContext -) : JvmPlugin, JvmPluginImpl(parentCoroutineContext) \ No newline at end of file +) : JvmPlugin, AbstractJvmPlugin(parentCoroutineContext) \ No newline at end of file