From 8ea0c538a091dfd3d95eb0aea2c8594e6f42ac3d Mon Sep 17 00:00:00 2001 From: Him188 Date: Sun, 24 May 2020 14:53:17 +0800 Subject: [PATCH] Add copyright --- .../scheduler/SchedulerTaskManager.java | 36 ------------------- .../mamoe/mirai/console/utils/BotManager.java | 19 +++++++--- .../net/mamoe/mirai/console/utils/Utils.java | 35 ------------------ .../mirai/console/center/CuiPluginCenter.kt | 9 +++++ .../mirai/console/center/PluginCenter.kt | 9 +++++ .../mirai/console/command/CommandManager.kt | 13 +++++-- .../command/description/CommandArgParser.kt | 9 +++++ .../CompositeCommand.CommandParam.kt | 9 +++++ .../console/event/CommandExecutionEvent.kt | 9 +++++ .../mamoe/mirai/console/event/ConsoleEvent.kt | 9 +++++ .../mirai/console/plugins/PluginLoader.kt | 9 +++++ .../mirai/console/plugins/PluginManager.kt | 9 +++++ .../plugins/builtin/JarPluginLoader.kt | 9 +++++ .../console/plugins/builtin/JvmPlugin.kt | 2 +- .../plugins/builtin/JvmPluginDescription.kt | 9 +++++ .../mamoe/mirai/console/utils/ConsoleInput.kt | 17 ++++----- .../console/utils/JavaPluginScheduler.kt | 9 +++++ .../mirai/console/utils/retryCatching.kt | 9 +++++ 18 files changed, 141 insertions(+), 89 deletions(-) delete mode 100644 backend/mirai-console/src/main/java/net/mamoe/mirai/console/scheduler/SchedulerTaskManager.java delete mode 100644 backend/mirai-console/src/main/java/net/mamoe/mirai/console/utils/Utils.java diff --git a/backend/mirai-console/src/main/java/net/mamoe/mirai/console/scheduler/SchedulerTaskManager.java b/backend/mirai-console/src/main/java/net/mamoe/mirai/console/scheduler/SchedulerTaskManager.java deleted file mode 100644 index 5c49b524a..000000000 --- a/backend/mirai-console/src/main/java/net/mamoe/mirai/console/scheduler/SchedulerTaskManager.java +++ /dev/null @@ -1,36 +0,0 @@ -package net.mamoe.mirai.console.scheduler; - -/** - * Java开发者的SchedulerTask - * 使用kt实现, java的API - */ - -/** - * PluginScheduler.RepeatTaskReceipt repeatTaskReceipt = this.getScheduler().repeat(() -> { - * getLogger().info("I repeat"); - * },100); - * - * - * this.getScheduler().delay(() -> { - * repeatTaskReceipt.setCancelled(true); - * },10000); - * - * - * Future future = this.getScheduler().async(() -> { - * //do some task - * return "success"; - * }); - * - * try { - * getLogger().info(future.get()); - * } catch (InterruptedException | ExecutionException e) { - * e.printStackTrace(); - * } - */ - -public class SchedulerTaskManager { - public static SchedulerTaskManagerInstance getInstance(){ - return SchedulerTaskManagerInstance.INSTANCE; - } -} - diff --git a/backend/mirai-console/src/main/java/net/mamoe/mirai/console/utils/BotManager.java b/backend/mirai-console/src/main/java/net/mamoe/mirai/console/utils/BotManager.java index 080ca51bb..c30422724 100644 --- a/backend/mirai-console/src/main/java/net/mamoe/mirai/console/utils/BotManager.java +++ b/backend/mirai-console/src/main/java/net/mamoe/mirai/console/utils/BotManager.java @@ -1,3 +1,12 @@ +/* + * 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 + */ + package net.mamoe.mirai.console.utils; import net.mamoe.mirai.Bot; @@ -5,8 +14,8 @@ import net.mamoe.mirai.Bot; import java.util.List; /** - * 获取Bot Manager - * Java友好API + * 获取 Bot Manager + * Java 友好 API */ public class BotManager { @@ -15,15 +24,15 @@ public class BotManager { return getManagers(bot); } - public static List getManagers(Bot bot){ + public static List getManagers(Bot bot) { return BotHelperKt.getBotManagers(bot); } - public static boolean isManager(Bot bot, long target){ + public static boolean isManager(Bot bot, long target) { return getManagers(bot).contains(target); } - public static boolean isManager(long botAccount, long target){ + public static boolean isManager(long botAccount, long target) { return getManagers(botAccount).contains(target); } } diff --git a/backend/mirai-console/src/main/java/net/mamoe/mirai/console/utils/Utils.java b/backend/mirai-console/src/main/java/net/mamoe/mirai/console/utils/Utils.java deleted file mode 100644 index 6f2c654db..000000000 --- a/backend/mirai-console/src/main/java/net/mamoe/mirai/console/utils/Utils.java +++ /dev/null @@ -1,35 +0,0 @@ -package net.mamoe.mirai.console.utils; - -import org.jetbrains.annotations.Range; - -import java.util.concurrent.Callable; - -public final class Utils { - - /** - * 执行N次 callable - * 成功一次就会结束 - * 否则就会throw - */ - public static T tryNTimes(@Range(from = 1, to = Integer.MAX_VALUE) int n, - Callable callable) throws Exception { - Exception last = null; - - while (n-- > 0) { - try { - return callable.call(); - } catch (Exception e) { - if (last == null) { - last = e; - } else { - try { - last.addSuppressed(e); - } catch (Throwable ignored) { - } - } - } - } - - throw last; - } -} diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/center/CuiPluginCenter.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/center/CuiPluginCenter.kt index 1c9c6ee23..2d911108d 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/center/CuiPluginCenter.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/center/CuiPluginCenter.kt @@ -1,3 +1,12 @@ +/* + * 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:OptIn(MiraiExperimentalAPI::class) package net.mamoe.mirai.console.center diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/center/PluginCenter.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/center/PluginCenter.kt index 26c4f63a7..deffd06dd 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/center/PluginCenter.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/center/PluginCenter.kt @@ -1,3 +1,12 @@ +/* + * 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 + */ + package net.mamoe.mirai.console.center import kotlinx.serialization.SerialName diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/CommandManager.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/CommandManager.kt index 63facd067..c9ff772ac 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/CommandManager.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/CommandManager.kt @@ -1,10 +1,19 @@ +/* + * 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("NOTHING_TO_INLINE", "unused") @file:JvmName("CommandManager") package net.mamoe.mirai.console.command import kotlinx.atomicfu.locks.withLock -import net.mamoe.mirai.console.plugins.PluginBase +import net.mamoe.mirai.console.plugins.Plugin import net.mamoe.mirai.message.data.Message import net.mamoe.mirai.message.data.MessageChain import net.mamoe.mirai.message.data.SingleMessage @@ -13,7 +22,7 @@ sealed class CommandOwner object TestCommandOwner : CommandOwner() -abstract class PluginCommandOwner(plugin: PluginBase) : CommandOwner() +abstract class PluginCommandOwner(plugin: Plugin) : CommandOwner() // 由前端实现 internal abstract class ConsoleCommandOwner : CommandOwner() diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/description/CommandArgParser.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/description/CommandArgParser.kt index 740f6d2e1..94acd0519 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/description/CommandArgParser.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/description/CommandArgParser.kt @@ -1,3 +1,12 @@ +/* + * 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("NOTHING_TO_INLINE") package net.mamoe.mirai.console.command.description diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/description/CompositeCommand.CommandParam.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/description/CompositeCommand.CommandParam.kt index b20dad891..2ac138bc5 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/description/CompositeCommand.CommandParam.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/description/CompositeCommand.CommandParam.kt @@ -1,3 +1,12 @@ +/* + * 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("unused") package net.mamoe.mirai.console.command.description diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/event/CommandExecutionEvent.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/event/CommandExecutionEvent.kt index 02dadb887..6a048337f 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/event/CommandExecutionEvent.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/event/CommandExecutionEvent.kt @@ -1,3 +1,12 @@ +/* + * 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 + */ + package net.mamoe.mirai.console.event import net.mamoe.mirai.console.command.Command diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/event/ConsoleEvent.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/event/ConsoleEvent.kt index 9a0504837..50b2aeff6 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/event/ConsoleEvent.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/event/ConsoleEvent.kt @@ -1,3 +1,12 @@ +/* + * 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 + */ + package net.mamoe.mirai.console.event import net.mamoe.mirai.event.Event diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugins/PluginLoader.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugins/PluginLoader.kt index 1194b9f03..43af25148 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugins/PluginLoader.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugins/PluginLoader.kt @@ -1,3 +1,12 @@ +/* + * 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("unused") package net.mamoe.mirai.console.plugins diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugins/PluginManager.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugins/PluginManager.kt index fcba50859..09724d3ee 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugins/PluginManager.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugins/PluginManager.kt @@ -1,3 +1,12 @@ +/* + * 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("NOTHING_TO_INLINE") package net.mamoe.mirai.console.plugins diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugins/builtin/JarPluginLoader.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugins/builtin/JarPluginLoader.kt index 0d132becd..a8077caec 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugins/builtin/JarPluginLoader.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugins/builtin/JarPluginLoader.kt @@ -1,3 +1,12 @@ +/* + * 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 + */ + package net.mamoe.mirai.console.plugins.builtin import kotlinx.coroutines.* diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugins/builtin/JvmPlugin.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugins/builtin/JvmPlugin.kt index 4fa0e4d10..970f0b8ae 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugins/builtin/JvmPlugin.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugins/builtin/JvmPlugin.kt @@ -6,8 +6,8 @@ * * https://github.com/mamoe/mirai/blob/master/LICENSE */ -@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE", "EXPOSED_SUPER_CLASS") +@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE", "EXPOSED_SUPER_CLASS") package net.mamoe.mirai.console.plugins.builtin diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugins/builtin/JvmPluginDescription.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugins/builtin/JvmPluginDescription.kt index b7e9e74ff..be5e73810 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugins/builtin/JvmPluginDescription.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugins/builtin/JvmPluginDescription.kt @@ -1,3 +1,12 @@ +/* + * 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 + */ + package net.mamoe.mirai.console.plugins.builtin import kotlinx.serialization.SerialName diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/utils/ConsoleInput.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/utils/ConsoleInput.kt index 8295c7012..75f66a8b0 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/utils/ConsoleInput.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/utils/ConsoleInput.kt @@ -11,7 +11,6 @@ package net.mamoe.mirai.console.utils import kotlinx.coroutines.* import net.mamoe.mirai.console.MiraiConsole -import net.mamoe.mirai.console.plugins.PluginBase import java.util.concurrent.Executors @Suppress("unused") @@ -25,30 +24,28 @@ object ConsoleInput { * 如弹出框,或一行字 */ suspend fun requestInput( - hint:String - ):String{ + hint: String + ): String { return withContext(inputDispatcher) { MiraiConsole.frontEnd.requestInput(hint) } } - fun requestInputBlocking(hint:String):String = runBlocking { requestInput(hint) } + fun requestInputBlocking(hint: String): String = runBlocking { requestInput(hint) } /** * asnyc获取 */ fun requestInputAsync( - pluginBase: PluginBase, + scope: CoroutineScope, hint: String - ):Deferred{ - return pluginBase.async { + ): Deferred { + return scope.async { requestInput(hint) } } - suspend fun MiraiConsole.requestInput(hint:String):String = requestInput(hint) - - suspend fun PluginBase.requestInputAsync(hint:String):Deferred = requestInputAsync(hint) + suspend fun MiraiConsole.requestInput(hint: String): String = requestInput(hint) } diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/utils/JavaPluginScheduler.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/utils/JavaPluginScheduler.kt index 826759aef..ab334872c 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/utils/JavaPluginScheduler.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/utils/JavaPluginScheduler.kt @@ -1,3 +1,12 @@ +/* + * 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 + */ + package net.mamoe.mirai.console.utils import kotlinx.coroutines.* diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/utils/retryCatching.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/utils/retryCatching.kt index a8c425921..2cdb0b423 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/utils/retryCatching.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/utils/retryCatching.kt @@ -1,3 +1,12 @@ +/* + * 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", "RESULT_CLASS_IN_RETURN_TYPE") package net.mamoe.mirai.console.utils