Forráskód Böngészése

Introduce AbstractJvmPlugin

Him188 5 éve
szülő
commit
1186083f09

+ 28 - 0
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 并绑定自动保存.
+}

+ 1 - 2
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

+ 3 - 1
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 插件

+ 1 - 2
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)
+) : JvmPlugin, AbstractJvmPlugin(parentCoroutineContext)