mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-10 18:40:15 +08:00
Merge remote-tracking branch 'origin/master' into logger
This commit is contained in:
commit
f1113bbcce
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 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.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
@ -17,7 +17,6 @@ import kotlinx.coroutines.Job
|
|||||||
import net.mamoe.mirai.Bot
|
import net.mamoe.mirai.Bot
|
||||||
import net.mamoe.mirai.console.MiraiConsole.INSTANCE
|
import net.mamoe.mirai.console.MiraiConsole.INSTANCE
|
||||||
import net.mamoe.mirai.console.MiraiConsoleImplementation.Companion.start
|
import net.mamoe.mirai.console.MiraiConsoleImplementation.Companion.start
|
||||||
import net.mamoe.mirai.console.command.BuiltInCommands
|
|
||||||
import net.mamoe.mirai.console.extensions.BotConfigurationAlterer
|
import net.mamoe.mirai.console.extensions.BotConfigurationAlterer
|
||||||
import net.mamoe.mirai.console.internal.MiraiConsoleImplementationBridge
|
import net.mamoe.mirai.console.internal.MiraiConsoleImplementationBridge
|
||||||
import net.mamoe.mirai.console.internal.extension.GlobalComponentStorage
|
import net.mamoe.mirai.console.internal.extension.GlobalComponentStorage
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
@ -49,7 +49,7 @@ public annotation class ConsoleFrontEndImplementation
|
|||||||
/**
|
/**
|
||||||
* 实现 [MiraiConsole] 的接口
|
* 实现 [MiraiConsole] 的接口
|
||||||
*
|
*
|
||||||
* **注意**: 随着 Console 的更新, 在版本号 `x.y.z` 的 `y` 修改时此接口可能就会变动. 意味着前端实现着需要跟随 Console 更新.
|
* **注意**: 随着 Console 的更新, 在版本号 `x.y.z` 的 `y` 修改时此接口可能就会发生 ABI 变动. 意味着前端实现着需要跟随 Console 更新.
|
||||||
*
|
*
|
||||||
* @see MiraiConsoleImplementation.start 启动
|
* @see MiraiConsoleImplementation.start 启动
|
||||||
*/
|
*/
|
@ -2,14 +2,17 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@file:Suppress("unused")
|
||||||
|
|
||||||
package net.mamoe.mirai.console.command
|
package net.mamoe.mirai.console.command
|
||||||
|
|
||||||
import net.mamoe.mirai.console.internal.command.createOrFindCommandPermission
|
import net.mamoe.mirai.console.command.descriptor.ExperimentalCommandDescriptors
|
||||||
|
import net.mamoe.mirai.console.internal.command.findOrCreateCommandPermission
|
||||||
import net.mamoe.mirai.console.permission.Permission
|
import net.mamoe.mirai.console.permission.Permission
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -26,14 +29,17 @@ public abstract class AbstractCommand
|
|||||||
public final override val secondaryNames: Array<out String>,
|
public final override val secondaryNames: Array<out String>,
|
||||||
public override val description: String = "<no description available>",
|
public override val description: String = "<no description available>",
|
||||||
parentPermission: Permission = owner.parentPermission,
|
parentPermission: Permission = owner.parentPermission,
|
||||||
/** 为 `true` 时表示 [指令前缀][CommandManager.commandPrefix] 可选 */
|
|
||||||
public override val prefixOptional: Boolean = false,
|
|
||||||
) : Command {
|
) : Command {
|
||||||
|
|
||||||
|
@ExperimentalCommandDescriptors
|
||||||
|
override val prefixOptional: Boolean
|
||||||
|
get() = false
|
||||||
|
|
||||||
init {
|
init {
|
||||||
Command.checkCommandName(primaryName)
|
Command.checkCommandName(primaryName)
|
||||||
secondaryNames.forEach(Command.Companion::checkCommandName)
|
secondaryNames.forEach(Command.Companion::checkCommandName)
|
||||||
}
|
}
|
||||||
|
|
||||||
public override val usage: String get() = description
|
public override val usage: String get() = description
|
||||||
public override val permission: Permission by lazy { createOrFindCommandPermission(parentPermission) }
|
public override val permission: Permission by lazy { findOrCreateCommandPermission(parentPermission) }
|
||||||
}
|
}
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
@ -71,13 +71,18 @@ public object BuiltInCommands {
|
|||||||
|
|
||||||
public object HelpCommand : SimpleCommand(
|
public object HelpCommand : SimpleCommand(
|
||||||
ConsoleCommandOwner, "help",
|
ConsoleCommandOwner, "help",
|
||||||
description = "Command list",
|
description = "查看指令帮助",
|
||||||
), BuiltInCommandInternal {
|
), BuiltInCommandInternal {
|
||||||
@Handler
|
@Handler
|
||||||
public suspend fun CommandSender.handle() {
|
public suspend fun CommandSender.handle() {
|
||||||
sendMessage(
|
sendMessage(
|
||||||
allRegisteredCommands.joinToString("\n\n") { "◆ ${it.usage}" }.lines().filterNot(String::isBlank)
|
allRegisteredCommands
|
||||||
.joinToString("\n")
|
.joinToString("\n\n") { command ->
|
||||||
|
val lines = command.usage.lines()
|
||||||
|
if (lines.isEmpty()) "/${command.primaryName} ${command.description}"
|
||||||
|
else
|
||||||
|
"◆ " + lines.first() + "\n" + lines.drop(1).joinToString("\n") { " $it" }
|
||||||
|
}.lines().filterNot(String::isBlank).joinToString("\n")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -90,7 +95,7 @@ public object BuiltInCommands {
|
|||||||
|
|
||||||
public object StopCommand : SimpleCommand(
|
public object StopCommand : SimpleCommand(
|
||||||
ConsoleCommandOwner, "stop", "shutdown", "exit",
|
ConsoleCommandOwner, "stop", "shutdown", "exit",
|
||||||
description = "Stop the whole world.",
|
description = "关闭 Mirai Console",
|
||||||
), BuiltInCommandInternal {
|
), BuiltInCommandInternal {
|
||||||
|
|
||||||
private val closingLock = Mutex()
|
private val closingLock = Mutex()
|
||||||
@ -125,10 +130,10 @@ public object BuiltInCommands {
|
|||||||
|
|
||||||
public object LoginCommand : SimpleCommand(
|
public object LoginCommand : SimpleCommand(
|
||||||
ConsoleCommandOwner, "login", "登录",
|
ConsoleCommandOwner, "login", "登录",
|
||||||
description = "Log in a bot account.",
|
description = "登录一个账号",
|
||||||
), BuiltInCommandInternal {
|
), BuiltInCommandInternal {
|
||||||
@Handler
|
@Handler
|
||||||
public suspend fun CommandSender.handle(id: Long, password: String) {
|
public suspend fun CommandSender.handle(@Name("qq") id: Long, password: String) {
|
||||||
kotlin.runCatching {
|
kotlin.runCatching {
|
||||||
MiraiConsole.addBot(id, password).alsoLogin()
|
MiraiConsole.addBot(id, password).alsoLogin()
|
||||||
}.fold(
|
}.fold(
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
@ -77,6 +77,9 @@ public interface Command {
|
|||||||
* 为 `true` 时表示 [指令前缀][CommandManager.commandPrefix] 可选.
|
* 为 `true` 时表示 [指令前缀][CommandManager.commandPrefix] 可选.
|
||||||
*
|
*
|
||||||
* 会影响聊天语境中的解析.
|
* 会影响聊天语境中的解析.
|
||||||
|
*
|
||||||
|
* #### 实验性 API
|
||||||
|
* 由于指令解析允许被扩展, 此属性可能不适用所有解析器, 因此还未决定是否保留.
|
||||||
*/
|
*/
|
||||||
@ExperimentalCommandDescriptors
|
@ExperimentalCommandDescriptors
|
||||||
@ConsoleExperimentalApi
|
@ConsoleExperimentalApi
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
@ -21,6 +21,8 @@ import kotlin.contracts.contract
|
|||||||
/**
|
/**
|
||||||
* 指令的执行返回
|
* 指令的执行返回
|
||||||
*
|
*
|
||||||
|
* 注意: 现阶段
|
||||||
|
*
|
||||||
* @see CommandExecuteStatus
|
* @see CommandExecuteStatus
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalApi("Not yet implemented")
|
@ConsoleExperimentalApi("Not yet implemented")
|
||||||
@ -144,12 +146,14 @@ public sealed class CommandExecuteResult {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ExperimentalCommandDescriptors
|
||||||
@Suppress("RemoveRedundantQualifierName")
|
@Suppress("RemoveRedundantQualifierName")
|
||||||
public typealias CommandExecuteStatus = CommandExecuteResult.CommandExecuteStatus
|
public typealias CommandExecuteStatus = CommandExecuteResult.CommandExecuteStatus
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当 [this] 为 [CommandExecuteResult.Success] 时返回 `true`
|
* 当 [this] 为 [CommandExecuteResult.Success] 时返回 `true`
|
||||||
*/
|
*/
|
||||||
|
@ExperimentalCommandDescriptors
|
||||||
@JvmSynthetic
|
@JvmSynthetic
|
||||||
public fun CommandExecuteResult.isSuccess(): Boolean {
|
public fun CommandExecuteResult.isSuccess(): Boolean {
|
||||||
contract {
|
contract {
|
||||||
@ -162,6 +166,7 @@ public fun CommandExecuteResult.isSuccess(): Boolean {
|
|||||||
/**
|
/**
|
||||||
* 当 [this] 为 [CommandExecuteResult.IllegalArgument] 时返回 `true`
|
* 当 [this] 为 [CommandExecuteResult.IllegalArgument] 时返回 `true`
|
||||||
*/
|
*/
|
||||||
|
@ExperimentalCommandDescriptors
|
||||||
@JvmSynthetic
|
@JvmSynthetic
|
||||||
public fun CommandExecuteResult.isIllegalArgument(): Boolean {
|
public fun CommandExecuteResult.isIllegalArgument(): Boolean {
|
||||||
contract {
|
contract {
|
||||||
@ -174,6 +179,7 @@ public fun CommandExecuteResult.isIllegalArgument(): Boolean {
|
|||||||
/**
|
/**
|
||||||
* 当 [this] 为 [CommandExecuteResult.ExecutionFailed] 时返回 `true`
|
* 当 [this] 为 [CommandExecuteResult.ExecutionFailed] 时返回 `true`
|
||||||
*/
|
*/
|
||||||
|
@ExperimentalCommandDescriptors
|
||||||
@JvmSynthetic
|
@JvmSynthetic
|
||||||
public fun CommandExecuteResult.isExecutionException(): Boolean {
|
public fun CommandExecuteResult.isExecutionException(): Boolean {
|
||||||
contract {
|
contract {
|
||||||
@ -186,6 +192,7 @@ public fun CommandExecuteResult.isExecutionException(): Boolean {
|
|||||||
/**
|
/**
|
||||||
* 当 [this] 为 [CommandExecuteResult.PermissionDenied] 时返回 `true`
|
* 当 [this] 为 [CommandExecuteResult.PermissionDenied] 时返回 `true`
|
||||||
*/
|
*/
|
||||||
|
@ExperimentalCommandDescriptors
|
||||||
@JvmSynthetic
|
@JvmSynthetic
|
||||||
public fun CommandExecuteResult.isPermissionDenied(): Boolean {
|
public fun CommandExecuteResult.isPermissionDenied(): Boolean {
|
||||||
contract {
|
contract {
|
||||||
@ -198,6 +205,7 @@ public fun CommandExecuteResult.isPermissionDenied(): Boolean {
|
|||||||
/**
|
/**
|
||||||
* 当 [this] 为 [CommandExecuteResult.UnresolvedCall] 时返回 `true`
|
* 当 [this] 为 [CommandExecuteResult.UnresolvedCall] 时返回 `true`
|
||||||
*/
|
*/
|
||||||
|
@ExperimentalCommandDescriptors
|
||||||
@JvmSynthetic
|
@JvmSynthetic
|
||||||
public fun CommandExecuteResult.isCommandNotFound(): Boolean {
|
public fun CommandExecuteResult.isCommandNotFound(): Boolean {
|
||||||
contract {
|
contract {
|
||||||
@ -210,6 +218,7 @@ public fun CommandExecuteResult.isCommandNotFound(): Boolean {
|
|||||||
/**
|
/**
|
||||||
* 当 [this] 为 [CommandExecuteResult.ExecutionFailed], [CommandExecuteResult.IllegalArgument] 或 [CommandExecuteResult.UnresolvedCall] 时返回 `true`
|
* 当 [this] 为 [CommandExecuteResult.ExecutionFailed], [CommandExecuteResult.IllegalArgument] 或 [CommandExecuteResult.UnresolvedCall] 时返回 `true`
|
||||||
*/
|
*/
|
||||||
|
@ExperimentalCommandDescriptors
|
||||||
@JvmSynthetic
|
@JvmSynthetic
|
||||||
public fun CommandExecuteResult.isFailure(): Boolean {
|
public fun CommandExecuteResult.isFailure(): Boolean {
|
||||||
contract {
|
contract {
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
@ -11,10 +11,8 @@
|
|||||||
|
|
||||||
package net.mamoe.mirai.console.command
|
package net.mamoe.mirai.console.command
|
||||||
|
|
||||||
import net.mamoe.mirai.console.command.CommandManager.INSTANCE.executeCommand
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 在 [CommandManager.executeCommand] 中, [Command.onCommand] 抛出异常时包装的异常.
|
* 在 [CommandManager.executeCommand] 中抛出异常时包装的异常.
|
||||||
*/
|
*/
|
||||||
public class CommandExecutionException(
|
public class CommandExecutionException(
|
||||||
/**
|
/**
|
||||||
@ -29,7 +27,7 @@ public class CommandExecutionException(
|
|||||||
* 匹配到的指令名
|
* 匹配到的指令名
|
||||||
*/
|
*/
|
||||||
public val name: String,
|
public val name: String,
|
||||||
cause: Throwable
|
cause: Throwable,
|
||||||
) : RuntimeException(
|
) : RuntimeException(
|
||||||
"Exception while executing command '${command.primaryName}'",
|
"Exception while executing command '${command.primaryName}'",
|
||||||
cause
|
cause
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -2,14 +2,13 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.mamoe.mirai.console.command
|
package net.mamoe.mirai.console.command
|
||||||
|
|
||||||
import net.mamoe.mirai.console.command.CommandManager.INSTANCE.unregisterAllCommands
|
|
||||||
import net.mamoe.mirai.console.compiler.common.ResolveContext
|
import net.mamoe.mirai.console.compiler.common.ResolveContext
|
||||||
import net.mamoe.mirai.console.compiler.common.ResolveContext.Kind.PERMISSION_NAME
|
import net.mamoe.mirai.console.compiler.common.ResolveContext.Kind.PERMISSION_NAME
|
||||||
import net.mamoe.mirai.console.permission.Permission
|
import net.mamoe.mirai.console.permission.Permission
|
||||||
@ -34,11 +33,13 @@ public interface CommandOwner : PermissionIdNamespace {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 代表控制台所有者. 所有的 mirai-console 内建的指令都属于 [ConsoleCommandOwner].
|
* 代表控制台所有者. 所有的 mirai-console 内建的指令都属于 [ConsoleCommandOwner].
|
||||||
|
*
|
||||||
|
* 插件注册指令时不应该使用 [ConsoleCommandOwner].
|
||||||
*/
|
*/
|
||||||
internal object ConsoleCommandOwner : CommandOwner {
|
public object ConsoleCommandOwner : CommandOwner {
|
||||||
override val parentPermission: Permission get() = BuiltInCommands.parentPermission
|
public override val parentPermission: Permission get() = BuiltInCommands.parentPermission
|
||||||
|
|
||||||
override fun permissionId(
|
public override fun permissionId(
|
||||||
@ResolveContext(PERMISSION_NAME) name: String,
|
@ResolveContext(PERMISSION_NAME) name: String,
|
||||||
): PermissionId = PermissionId("console", name)
|
): PermissionId = PermissionId("console", name)
|
||||||
}
|
}
|
@ -2,15 +2,13 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.mamoe.mirai.console.command
|
package net.mamoe.mirai.console.command
|
||||||
|
|
||||||
import net.mamoe.mirai.console.command.CommandManager.INSTANCE.executeCommand
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 在 [CommandManager.executeCommand] 中, [CommandSender] 未拥有 [Command.permission] 所要求的权限时抛出的异常.
|
* 在 [CommandManager.executeCommand] 中, [CommandSender] 未拥有 [Command.permission] 所要求的权限时抛出的异常.
|
||||||
*
|
*
|
||||||
@ -24,7 +22,7 @@ public class CommandPermissionDeniedException(
|
|||||||
/**
|
/**
|
||||||
* 执行过程发生异常的指令
|
* 执行过程发生异常的指令
|
||||||
*/
|
*/
|
||||||
public val command: Command
|
public val command: Command,
|
||||||
) : RuntimeException("Permission denied while executing command '${command.primaryName}'") {
|
) : RuntimeException("Permission denied while executing command '${command.primaryName}'") {
|
||||||
public override fun toString(): String =
|
public override fun toString(): String =
|
||||||
"CommandPermissionDeniedException(command=$command)"
|
"CommandPermissionDeniedException(command=$command)"
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
@ -87,9 +87,8 @@ public abstract class CompositeCommand(
|
|||||||
@ResolveContext(COMMAND_NAME) vararg secondaryNames: String,
|
@ResolveContext(COMMAND_NAME) vararg secondaryNames: String,
|
||||||
description: String = "no description available",
|
description: String = "no description available",
|
||||||
parentPermission: Permission = owner.parentPermission,
|
parentPermission: Permission = owner.parentPermission,
|
||||||
prefixOptional: Boolean = false,
|
|
||||||
overrideContext: CommandArgumentContext = EmptyCommandArgumentContext,
|
overrideContext: CommandArgumentContext = EmptyCommandArgumentContext,
|
||||||
) : Command, AbstractCommand(owner, primaryName, secondaryNames = secondaryNames, description, parentPermission, prefixOptional),
|
) : Command, AbstractCommand(owner, primaryName, secondaryNames = secondaryNames, description, parentPermission),
|
||||||
CommandArgumentContextAware {
|
CommandArgumentContextAware {
|
||||||
|
|
||||||
private val reflector by lazy { CommandReflector(this, CompositeCommandSubCommandAnnotationResolver) }
|
private val reflector by lazy { CommandReflector(this, CompositeCommandSubCommandAnnotationResolver) }
|
@ -2,10 +2,9 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@file:Suppress("unused")
|
@file:Suppress("unused")
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
@ -15,7 +15,7 @@ import net.mamoe.mirai.console.command.descriptor.*
|
|||||||
import net.mamoe.mirai.console.command.java.JRawCommand
|
import net.mamoe.mirai.console.command.java.JRawCommand
|
||||||
import net.mamoe.mirai.console.compiler.common.ResolveContext
|
import net.mamoe.mirai.console.compiler.common.ResolveContext
|
||||||
import net.mamoe.mirai.console.compiler.common.ResolveContext.Kind.COMMAND_NAME
|
import net.mamoe.mirai.console.compiler.common.ResolveContext.Kind.COMMAND_NAME
|
||||||
import net.mamoe.mirai.console.internal.command.createOrFindCommandPermission
|
import net.mamoe.mirai.console.internal.command.findOrCreateCommandPermission
|
||||||
import net.mamoe.mirai.console.internal.data.typeOf0
|
import net.mamoe.mirai.console.internal.data.typeOf0
|
||||||
import net.mamoe.mirai.console.permission.Permission
|
import net.mamoe.mirai.console.permission.Permission
|
||||||
import net.mamoe.mirai.message.data.Message
|
import net.mamoe.mirai.message.data.Message
|
||||||
@ -53,7 +53,7 @@ public abstract class RawCommand(
|
|||||||
@OptIn(ExperimentalCommandDescriptors::class)
|
@OptIn(ExperimentalCommandDescriptors::class)
|
||||||
public override val prefixOptional: Boolean = false,
|
public override val prefixOptional: Boolean = false,
|
||||||
) : Command {
|
) : Command {
|
||||||
public override val permission: Permission by lazy { createOrFindCommandPermission(parentPermission) }
|
public override val permission: Permission by lazy { findOrCreateCommandPermission(parentPermission) }
|
||||||
|
|
||||||
@ExperimentalCommandDescriptors
|
@ExperimentalCommandDescriptors
|
||||||
override val overloads: List<CommandSignature> = listOf(
|
override val overloads: List<CommandSignature> = listOf(
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
@ -58,9 +58,8 @@ public abstract class SimpleCommand(
|
|||||||
@ResolveContext(COMMAND_NAME) vararg secondaryNames: String,
|
@ResolveContext(COMMAND_NAME) vararg secondaryNames: String,
|
||||||
description: String = "no description available",
|
description: String = "no description available",
|
||||||
parentPermission: Permission = owner.parentPermission,
|
parentPermission: Permission = owner.parentPermission,
|
||||||
prefixOptional: Boolean = false,
|
|
||||||
overrideContext: CommandArgumentContext = EmptyCommandArgumentContext,
|
overrideContext: CommandArgumentContext = EmptyCommandArgumentContext,
|
||||||
) : Command, AbstractCommand(owner, primaryName, secondaryNames = secondaryNames, description, parentPermission, prefixOptional),
|
) : Command, AbstractCommand(owner, primaryName, secondaryNames = secondaryNames, description, parentPermission),
|
||||||
CommandArgumentContextAware {
|
CommandArgumentContextAware {
|
||||||
|
|
||||||
private val reflector by lazy { CommandReflector(this, SimpleCommandSubCommandAnnotationResolver) }
|
private val reflector by lazy { CommandReflector(this, SimpleCommandSubCommandAnnotationResolver) }
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
@ -109,7 +109,7 @@ public object PlainTextValueArgumentParser : InternalCommandValueArgumentParserE
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当字符串内容为(不区分大小写) "true", "yes", "enabled"
|
* 当字符串内容为(不区分大小写) "true", "yes", "enabled", "on", "1"
|
||||||
*/
|
*/
|
||||||
public object BooleanValueArgumentParser : InternalCommandValueArgumentParserExtensions<Boolean>() {
|
public object BooleanValueArgumentParser : InternalCommandValueArgumentParserExtensions<Boolean>() {
|
||||||
public override fun parse(raw: String, sender: CommandSender): Boolean = raw.trim().let { str ->
|
public override fun parse(raw: String, sender: CommandSender): Boolean = raw.trim().let { str ->
|
||||||
@ -117,6 +117,7 @@ public object BooleanValueArgumentParser : InternalCommandValueArgumentParserExt
|
|||||||
|| str.equals("yes", ignoreCase = true)
|
|| str.equals("yes", ignoreCase = true)
|
||||||
|| str.equals("enabled", ignoreCase = true)
|
|| str.equals("enabled", ignoreCase = true)
|
||||||
|| str.equals("on", ignoreCase = true)
|
|| str.equals("on", ignoreCase = true)
|
||||||
|
|| str.equals("1", ignoreCase = true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 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.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
@ -14,93 +14,17 @@ import net.mamoe.mirai.console.command.descriptor.AbstractCommandValueParameter.
|
|||||||
import net.mamoe.mirai.console.command.descriptor.AbstractCommandValueParameter.UserDefinedType.Companion.createRequired
|
import net.mamoe.mirai.console.command.descriptor.AbstractCommandValueParameter.UserDefinedType.Companion.createRequired
|
||||||
import net.mamoe.mirai.console.command.descriptor.ArgumentAcceptance.Companion.isAcceptable
|
import net.mamoe.mirai.console.command.descriptor.ArgumentAcceptance.Companion.isAcceptable
|
||||||
import net.mamoe.mirai.console.command.parse.CommandValueArgument
|
import net.mamoe.mirai.console.command.parse.CommandValueArgument
|
||||||
import net.mamoe.mirai.console.command.resolve.ResolvedCommandCall
|
|
||||||
import net.mamoe.mirai.console.internal.data.classifierAsKClass
|
import net.mamoe.mirai.console.internal.data.classifierAsKClass
|
||||||
import net.mamoe.mirai.console.internal.data.classifierAsKClassOrNull
|
import net.mamoe.mirai.console.internal.data.classifierAsKClassOrNull
|
||||||
import net.mamoe.mirai.console.internal.data.typeOf0
|
import net.mamoe.mirai.console.internal.data.typeOf0
|
||||||
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
|
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
|
||||||
|
import net.mamoe.mirai.message.data.content
|
||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
import kotlin.reflect.KFunction
|
|
||||||
import kotlin.reflect.KType
|
import kotlin.reflect.KType
|
||||||
import kotlin.reflect.full.isSubclassOf
|
import kotlin.reflect.full.isSubclassOf
|
||||||
import kotlin.reflect.full.isSubtypeOf
|
import kotlin.reflect.full.isSubtypeOf
|
||||||
import kotlin.reflect.typeOf
|
import kotlin.reflect.typeOf
|
||||||
|
|
||||||
/**
|
|
||||||
* 指令签名. 表示指令定义的需要的参数.
|
|
||||||
*
|
|
||||||
* @see AbstractCommandSignature
|
|
||||||
*/
|
|
||||||
@ExperimentalCommandDescriptors
|
|
||||||
public interface CommandSignature {
|
|
||||||
/**
|
|
||||||
* 接收者参数, 为 [CommandSender] 子类
|
|
||||||
*/
|
|
||||||
@ConsoleExperimentalApi
|
|
||||||
public val receiverParameter: CommandReceiverParameter<out CommandSender>?
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 形式 值参数.
|
|
||||||
*/
|
|
||||||
public val valueParameters: List<AbstractCommandValueParameter<*>>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 调用这个指令.
|
|
||||||
*/
|
|
||||||
public suspend fun call(resolvedCommandCall: ResolvedCommandCall)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 来自 [KFunction] 反射得到的 [CommandSignature]
|
|
||||||
*
|
|
||||||
* @see CommandSignatureFromKFunctionImpl
|
|
||||||
*/
|
|
||||||
@ConsoleExperimentalApi
|
|
||||||
@ExperimentalCommandDescriptors
|
|
||||||
public interface CommandSignatureFromKFunction : CommandSignature {
|
|
||||||
public val originFunction: KFunction<*>
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see CommandSignatureImpl
|
|
||||||
* @see CommandSignatureFromKFunctionImpl
|
|
||||||
*/
|
|
||||||
@ExperimentalCommandDescriptors
|
|
||||||
public abstract class AbstractCommandSignature : CommandSignature {
|
|
||||||
override fun toString(): String {
|
|
||||||
val receiverParameter = receiverParameter
|
|
||||||
return if (receiverParameter == null) {
|
|
||||||
"CommandSignatureVariant(${valueParameters.joinToString()})"
|
|
||||||
} else {
|
|
||||||
"CommandSignatureVariant($receiverParameter, ${valueParameters.joinToString()})"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@ExperimentalCommandDescriptors
|
|
||||||
public open class CommandSignatureImpl(
|
|
||||||
override val receiverParameter: CommandReceiverParameter<out CommandSender>?,
|
|
||||||
override val valueParameters: List<AbstractCommandValueParameter<*>>,
|
|
||||||
private val onCall: suspend CommandSignatureImpl.(resolvedCommandCall: ResolvedCommandCall) -> Unit,
|
|
||||||
) : CommandSignature, AbstractCommandSignature() {
|
|
||||||
override suspend fun call(resolvedCommandCall: ResolvedCommandCall) {
|
|
||||||
return onCall(resolvedCommandCall)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@ConsoleExperimentalApi
|
|
||||||
@ExperimentalCommandDescriptors
|
|
||||||
public open class CommandSignatureFromKFunctionImpl(
|
|
||||||
override val receiverParameter: CommandReceiverParameter<out CommandSender>?,
|
|
||||||
override val valueParameters: List<AbstractCommandValueParameter<*>>,
|
|
||||||
override val originFunction: KFunction<*>,
|
|
||||||
private val onCall: suspend CommandSignatureFromKFunctionImpl.(resolvedCommandCall: ResolvedCommandCall) -> Unit,
|
|
||||||
) : CommandSignatureFromKFunction, AbstractCommandSignature() {
|
|
||||||
override suspend fun call(resolvedCommandCall: ResolvedCommandCall) {
|
|
||||||
return onCall(resolvedCommandCall)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inherited instances must be [CommandValueParameter] or [CommandReceiverParameter]
|
* Inherited instances must be [CommandValueParameter] or [CommandReceiverParameter]
|
||||||
@ -181,7 +105,7 @@ public class CommandReceiverParameter<T : CommandSender>(
|
|||||||
override val isOptional: Boolean,
|
override val isOptional: Boolean,
|
||||||
override val type: KType,
|
override val type: KType,
|
||||||
) : CommandParameter<T>, AbstractCommandParameter<T>() {
|
) : CommandParameter<T>, AbstractCommandParameter<T>() {
|
||||||
override val name: String get() = PARAMETER_NAME
|
override val name: String get() = NAME
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val classifier = type.classifier
|
val classifier = type.classifier
|
||||||
@ -194,7 +118,7 @@ public class CommandReceiverParameter<T : CommandSender>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
public companion object {
|
public companion object {
|
||||||
public const val PARAMETER_NAME: String = "<receiver>"
|
public const val NAME: String = "<receiver>"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,7 +145,7 @@ public sealed class AbstractCommandValueParameter<T> : CommandValueParameter<T>,
|
|||||||
return acceptingImpl(this.type, argument, commandArgumentContext)
|
return acceptingImpl(this.type, argument, commandArgumentContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun acceptingImpl(
|
protected open fun acceptingImpl(
|
||||||
expectingType: KType,
|
expectingType: KType,
|
||||||
argument: CommandValueArgument,
|
argument: CommandValueArgument,
|
||||||
commandArgumentContext: CommandArgumentContext?,
|
commandArgumentContext: CommandArgumentContext?,
|
||||||
@ -261,6 +185,12 @@ public sealed class AbstractCommandValueParameter<T> : CommandValueParameter<T>,
|
|||||||
|
|
||||||
override fun toString(): String = "<$expectingValue>"
|
override fun toString(): String = "<$expectingValue>"
|
||||||
|
|
||||||
|
override fun acceptingImpl(expectingType: KType, argument: CommandValueArgument, commandArgumentContext: CommandArgumentContext?): ArgumentAcceptance {
|
||||||
|
return if (argument.value.content == expectingValue) {
|
||||||
|
ArgumentAcceptance.Direct
|
||||||
|
} else ArgumentAcceptance.Impossible
|
||||||
|
}
|
||||||
|
|
||||||
private companion object {
|
private companion object {
|
||||||
@OptIn(ExperimentalStdlibApi::class)
|
@OptIn(ExperimentalStdlibApi::class)
|
||||||
val STRING_TYPE = typeOf<String>()
|
val STRING_TYPE = typeOf<String>()
|
@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
|
*
|
||||||
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
|
*
|
||||||
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.mamoe.mirai.console.command.descriptor
|
||||||
|
|
||||||
|
import net.mamoe.mirai.console.command.CommandSender
|
||||||
|
import net.mamoe.mirai.console.command.resolve.ResolvedCommandCall
|
||||||
|
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
|
||||||
|
import kotlin.reflect.KFunction
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 指令签名. 表示指令定义的需要的参数.
|
||||||
|
*
|
||||||
|
* @see AbstractCommandSignature
|
||||||
|
*/
|
||||||
|
@ExperimentalCommandDescriptors
|
||||||
|
public interface CommandSignature {
|
||||||
|
/**
|
||||||
|
* 接收者参数, 为 [CommandSender] 子类
|
||||||
|
*/
|
||||||
|
@ConsoleExperimentalApi
|
||||||
|
public val receiverParameter: CommandReceiverParameter<out CommandSender>?
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 形式 值参数.
|
||||||
|
*/
|
||||||
|
public val valueParameters: List<AbstractCommandValueParameter<*>>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调用这个指令.
|
||||||
|
*/
|
||||||
|
public suspend fun call(resolvedCommandCall: ResolvedCommandCall)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 来自 [KFunction] 反射得到的 [CommandSignature]
|
||||||
|
*
|
||||||
|
* @see CommandSignatureFromKFunctionImpl
|
||||||
|
*/
|
||||||
|
@ConsoleExperimentalApi
|
||||||
|
@ExperimentalCommandDescriptors
|
||||||
|
public interface CommandSignatureFromKFunction : CommandSignature {
|
||||||
|
public val originFunction: KFunction<*>
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see CommandSignatureImpl
|
||||||
|
* @see CommandSignatureFromKFunctionImpl
|
||||||
|
*/
|
||||||
|
@ExperimentalCommandDescriptors
|
||||||
|
public abstract class AbstractCommandSignature : CommandSignature {
|
||||||
|
override fun toString(): String {
|
||||||
|
val receiverParameter = receiverParameter
|
||||||
|
return if (receiverParameter == null) {
|
||||||
|
"CommandSignatureVariant(${valueParameters.joinToString()})"
|
||||||
|
} else {
|
||||||
|
"CommandSignatureVariant($receiverParameter, ${valueParameters.joinToString()})"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ExperimentalCommandDescriptors
|
||||||
|
public open class CommandSignatureImpl(
|
||||||
|
override val receiverParameter: CommandReceiverParameter<out CommandSender>?,
|
||||||
|
override val valueParameters: List<AbstractCommandValueParameter<*>>,
|
||||||
|
private val onCall: suspend CommandSignatureImpl.(resolvedCommandCall: ResolvedCommandCall) -> Unit,
|
||||||
|
) : CommandSignature, AbstractCommandSignature() {
|
||||||
|
override suspend fun call(resolvedCommandCall: ResolvedCommandCall) {
|
||||||
|
return onCall(resolvedCommandCall)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ConsoleExperimentalApi
|
||||||
|
@ExperimentalCommandDescriptors
|
||||||
|
public open class CommandSignatureFromKFunctionImpl(
|
||||||
|
override val receiverParameter: CommandReceiverParameter<out CommandSender>?,
|
||||||
|
override val valueParameters: List<AbstractCommandValueParameter<*>>,
|
||||||
|
override val originFunction: KFunction<*>,
|
||||||
|
private val onCall: suspend CommandSignatureFromKFunctionImpl.(resolvedCommandCall: ResolvedCommandCall) -> Unit,
|
||||||
|
) : CommandSignatureFromKFunction, AbstractCommandSignature() {
|
||||||
|
override suspend fun call(resolvedCommandCall: ResolvedCommandCall) {
|
||||||
|
return onCall(resolvedCommandCall)
|
||||||
|
}
|
||||||
|
}
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 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.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 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.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 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.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
@ -16,7 +16,7 @@ import net.mamoe.mirai.console.command.CommandOwner
|
|||||||
import net.mamoe.mirai.console.command.descriptor.ExperimentalCommandDescriptors
|
import net.mamoe.mirai.console.command.descriptor.ExperimentalCommandDescriptors
|
||||||
import net.mamoe.mirai.console.compiler.common.ResolveContext
|
import net.mamoe.mirai.console.compiler.common.ResolveContext
|
||||||
import net.mamoe.mirai.console.compiler.common.ResolveContext.Kind.COMMAND_NAME
|
import net.mamoe.mirai.console.compiler.common.ResolveContext.Kind.COMMAND_NAME
|
||||||
import net.mamoe.mirai.console.internal.command.createOrFindCommandPermission
|
import net.mamoe.mirai.console.internal.command.findOrCreateCommandPermission
|
||||||
import net.mamoe.mirai.console.permission.Permission
|
import net.mamoe.mirai.console.permission.Permission
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -65,7 +65,7 @@ public abstract class JRawCommand
|
|||||||
protected set
|
protected set
|
||||||
|
|
||||||
/** 指令权限 */
|
/** 指令权限 */
|
||||||
public final override var permission: Permission = createOrFindCommandPermission(parentPermission)
|
public final override var permission: Permission = findOrCreateCommandPermission(parentPermission)
|
||||||
protected set
|
protected set
|
||||||
|
|
||||||
/** 为 `true` 时表示 [指令前缀][CommandManager.commandPrefix] 可选 */
|
/** 为 `true` 时表示 [指令前缀][CommandManager.commandPrefix] 可选 */
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 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.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -1,3 +1,12 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
|
*
|
||||||
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
|
*
|
||||||
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
|
*/
|
||||||
|
|
||||||
package net.mamoe.mirai.console.command.parse
|
package net.mamoe.mirai.console.command.parse
|
||||||
|
|
||||||
import net.mamoe.mirai.console.command.CommandSender
|
import net.mamoe.mirai.console.command.CommandSender
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 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.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -1,3 +1,12 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
|
*
|
||||||
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
|
*
|
||||||
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
|
*/
|
||||||
|
|
||||||
package net.mamoe.mirai.console.command.parse
|
package net.mamoe.mirai.console.command.parse
|
||||||
|
|
||||||
import net.mamoe.mirai.console.command.CommandSender
|
import net.mamoe.mirai.console.command.CommandSender
|
@ -1,3 +1,12 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
|
*
|
||||||
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
|
*
|
||||||
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
|
*/
|
||||||
|
|
||||||
package net.mamoe.mirai.console.command.resolve
|
package net.mamoe.mirai.console.command.resolve
|
||||||
|
|
||||||
import net.mamoe.mirai.console.command.Command
|
import net.mamoe.mirai.console.command.Command
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 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.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 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.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 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.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 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.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
@ -23,6 +23,9 @@ import kotlin.reflect.KProperty
|
|||||||
/**
|
/**
|
||||||
* [PluginData] 的默认实现. 支持使用 `by value()` 等委托方法创建 [Value] 并跟踪其改动.
|
* [PluginData] 的默认实现. 支持使用 `by value()` 等委托方法创建 [Value] 并跟踪其改动.
|
||||||
*
|
*
|
||||||
|
* ### 实现注意
|
||||||
|
* 此类型处于实验性阶段. 使用其中定义的属性和函数是安全的, 但将来可能会新增成员抽象函数.
|
||||||
|
*
|
||||||
* @see PluginData
|
* @see PluginData
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractPluginData : PluginData, PluginDataImpl() {
|
public abstract class AbstractPluginData : PluginData, PluginDataImpl() {
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 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.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
@ -23,10 +23,4 @@ import kotlinx.coroutines.Job
|
|||||||
* @see PluginConfig
|
* @see PluginConfig
|
||||||
* @see AutoSavePluginData
|
* @see AutoSavePluginData
|
||||||
*/
|
*/
|
||||||
public open class AutoSavePluginConfig : AutoSavePluginData, PluginConfig {
|
public open class AutoSavePluginConfig public constructor(saveName: String) : AutoSavePluginData(saveName), PluginConfig
|
||||||
@Deprecated("请手动指定保存名称. 此构造器将在 1.0.0 删除", level = DeprecationLevel.ERROR, replaceWith = ReplaceWith("AutoSavePluginConfig(\"把我改成保存名称\")"))
|
|
||||||
@Suppress("DEPRECATION_ERROR")
|
|
||||||
public constructor() : super()
|
|
||||||
|
|
||||||
public constructor(saveName: String) : super(saveName)
|
|
||||||
}
|
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
@ -18,7 +18,6 @@ import net.mamoe.mirai.console.internal.data.qualifiedNameOrTip
|
|||||||
import net.mamoe.mirai.console.internal.plugin.updateWhen
|
import net.mamoe.mirai.console.internal.plugin.updateWhen
|
||||||
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
|
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
|
||||||
import net.mamoe.mirai.utils.*
|
import net.mamoe.mirai.utils.*
|
||||||
import kotlin.reflect.full.findAnnotation
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 链接自动保存的 [PluginData].
|
* 链接自动保存的 [PluginData].
|
||||||
@ -46,14 +45,6 @@ public open class AutoSavePluginData private constructor(
|
|||||||
_saveName = saveName
|
_saveName = saveName
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated("请手动指定保存名称. 此构造器将在 1.0.0 删除", level = DeprecationLevel.ERROR, replaceWith = ReplaceWith("AutoSavePluginData(\"把我改成保存名称\")"))
|
|
||||||
public constructor() : this(null) {
|
|
||||||
val clazz = this::class
|
|
||||||
_saveName = clazz.findAnnotation<ValueName>()?.value
|
|
||||||
?: clazz.qualifiedName
|
|
||||||
?: throw IllegalArgumentException("Cannot find a serial name for ${this::class}")
|
|
||||||
}
|
|
||||||
|
|
||||||
@ConsoleExperimentalApi
|
@ConsoleExperimentalApi
|
||||||
override fun onInit(owner: PluginDataHolder, storage: PluginDataStorage) {
|
override fun onInit(owner: PluginDataHolder, storage: PluginDataStorage) {
|
||||||
check(owner is AutoSavePluginDataHolder) { "owner must be AutoSavePluginDataHolder for AutoSavePluginData" }
|
check(owner is AutoSavePluginDataHolder) { "owner must be AutoSavePluginDataHolder for AutoSavePluginData" }
|
@ -1,3 +1,12 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
|
*
|
||||||
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
|
*
|
||||||
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
|
*/
|
||||||
|
|
||||||
package net.mamoe.mirai.console.data
|
package net.mamoe.mirai.console.data
|
||||||
|
|
||||||
import kotlinx.coroutines.CoroutineExceptionHandler
|
import kotlinx.coroutines.CoroutineExceptionHandler
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
@ -98,13 +98,16 @@ import kotlin.reflect.KType
|
|||||||
* ```
|
* ```
|
||||||
* // MyPluginData.nestedMap: MutableMap<Long, List<Long>> by value()
|
* // MyPluginData.nestedMap: MutableMap<Long, List<Long>> by value()
|
||||||
* val newList = MyPluginData.map.getOrPut(1, ::mutableListOf)
|
* val newList = MyPluginData.map.getOrPut(1, ::mutableListOf)
|
||||||
* newList.add(1) // 不会添加到 MyPluginData.nestedMap 中, 因为 `mutableListOf` 创建的 MutableList 被非引用地添加进了 MyPluginData.nestedMap
|
* newList.add(1) // 不会添加到 MyPluginData.nestedMap 中, 因为 `mutableListOf` 创建的 MutableList 被非引用 (浅拷贝) 地添加进了 MyPluginData.nestedMap
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* 一个解决方案是对 [SerializerAwareValue] 做映射或相关修改. 如 [PluginDataExtensions].
|
* 一个解决方案是对 [SerializerAwareValue] 做映射或相关修改. 如 [PluginDataExtensions].
|
||||||
*
|
*
|
||||||
* 要查看详细的解释,请查看 [docs/PluginData.md](https://github.com/mamoe/mirai-console/blob/master/docs/PluginData.md)
|
* 要查看详细的解释,请查看 [docs/PluginData.md](https://github.com/mamoe/mirai-console/blob/master/docs/PluginData.md)
|
||||||
*
|
*
|
||||||
|
* ## 实现注意
|
||||||
|
* 此类型处于实验性阶段. 使用其中定义的属性和函数是安全的, 但将来可能会新增成员抽象函数.
|
||||||
|
*
|
||||||
* @see AbstractJvmPlugin.reloadPluginData 通过 [JvmPlugin] 获取指定 [PluginData] 实例.
|
* @see AbstractJvmPlugin.reloadPluginData 通过 [JvmPlugin] 获取指定 [PluginData] 实例.
|
||||||
* @see PluginDataStorage [PluginData] 存储仓库
|
* @see PluginDataStorage [PluginData] 存储仓库
|
||||||
* @see PluginDataExtensions 相关 [SerializerAwareValue] 映射函数
|
* @see PluginDataExtensions 相关 [SerializerAwareValue] 映射函数
|
@ -1,3 +1,12 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
|
*
|
||||||
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
|
*
|
||||||
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
|
*/
|
||||||
|
|
||||||
@file:Suppress("unused", "INAPPLICABLE_JVM_NAME", "INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
|
@file:Suppress("unused", "INAPPLICABLE_JVM_NAME", "INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
|
||||||
|
|
||||||
package net.mamoe.mirai.console.data
|
package net.mamoe.mirai.console.data
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
@ -156,6 +156,7 @@ public interface SerializerAwareValue<T> : Value<T> {
|
|||||||
* 注意: 目前这些类型都会被装箱, 由于泛型 T. 在将来可能会有优化处理.
|
* 注意: 目前这些类型都会被装箱, 由于泛型 T. 在将来可能会有优化处理.
|
||||||
* *Primitive* 仅表示一个类型是上面 9 种类型之一.
|
* *Primitive* 仅表示一个类型是上面 9 种类型之一.
|
||||||
*/
|
*/
|
||||||
|
@ConsoleExperimentalApi
|
||||||
public interface PrimitiveValue<T> : Value<T>
|
public interface PrimitiveValue<T> : Value<T>
|
||||||
|
|
||||||
|
|
||||||
@ -164,46 +165,55 @@ public interface PrimitiveValue<T> : Value<T>
|
|||||||
/**
|
/**
|
||||||
* 表示一个不可空 [Byte] [Value].
|
* 表示一个不可空 [Byte] [Value].
|
||||||
*/
|
*/
|
||||||
|
@ConsoleExperimentalApi
|
||||||
public interface ByteValue : PrimitiveValue<Byte>
|
public interface ByteValue : PrimitiveValue<Byte>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表示一个不可空 [Short] [Value].
|
* 表示一个不可空 [Short] [Value].
|
||||||
*/
|
*/
|
||||||
|
@ConsoleExperimentalApi
|
||||||
public interface ShortValue : PrimitiveValue<Short>
|
public interface ShortValue : PrimitiveValue<Short>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表示一个不可空 [Int] [Value].
|
* 表示一个不可空 [Int] [Value].
|
||||||
*/
|
*/
|
||||||
|
@ConsoleExperimentalApi
|
||||||
public interface IntValue : PrimitiveValue<Int>
|
public interface IntValue : PrimitiveValue<Int>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表示一个不可空 [Long] [Value].
|
* 表示一个不可空 [Long] [Value].
|
||||||
*/
|
*/
|
||||||
|
@ConsoleExperimentalApi
|
||||||
public interface LongValue : PrimitiveValue<Long>
|
public interface LongValue : PrimitiveValue<Long>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表示一个不可空 [Float] [Value].
|
* 表示一个不可空 [Float] [Value].
|
||||||
*/
|
*/
|
||||||
|
@ConsoleExperimentalApi
|
||||||
public interface FloatValue : PrimitiveValue<Float>
|
public interface FloatValue : PrimitiveValue<Float>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表示一个不可空 [Double] [Value].
|
* 表示一个不可空 [Double] [Value].
|
||||||
*/
|
*/
|
||||||
|
@ConsoleExperimentalApi
|
||||||
public interface DoubleValue : PrimitiveValue<Double>
|
public interface DoubleValue : PrimitiveValue<Double>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表示一个不可空 [Char] [Value].
|
* 表示一个不可空 [Char] [Value].
|
||||||
*/
|
*/
|
||||||
|
@ConsoleExperimentalApi
|
||||||
public interface CharValue : PrimitiveValue<Char>
|
public interface CharValue : PrimitiveValue<Char>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表示一个不可空 [Boolean] [Value].
|
* 表示一个不可空 [Boolean] [Value].
|
||||||
*/
|
*/
|
||||||
|
@ConsoleExperimentalApi
|
||||||
public interface BooleanValue : PrimitiveValue<Boolean>
|
public interface BooleanValue : PrimitiveValue<Boolean>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表示一个不可空 [String] [Value].
|
* 表示一个不可空 [String] [Value].
|
||||||
*/
|
*/
|
||||||
|
@ConsoleExperimentalApi
|
||||||
public interface StringValue : PrimitiveValue<String>
|
public interface StringValue : PrimitiveValue<String>
|
||||||
|
|
||||||
//// endregion PrimitiveValues CODEGEN ////
|
//// endregion PrimitiveValues CODEGEN ////
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
@ -35,4 +35,9 @@ import kotlinx.serialization.SerialInfo
|
|||||||
@SerialInfo
|
@SerialInfo
|
||||||
@Target(AnnotationTarget.PROPERTY, AnnotationTarget.CLASS)
|
@Target(AnnotationTarget.PROPERTY, AnnotationTarget.CLASS)
|
||||||
@Retention(AnnotationRetention.RUNTIME)
|
@Retention(AnnotationRetention.RUNTIME)
|
||||||
public annotation class ValueDescription(val value: String)
|
public annotation class ValueDescription(
|
||||||
|
/**
|
||||||
|
* 将会被 [String.trimIndent] 处理.
|
||||||
|
*/
|
||||||
|
val value: String,
|
||||||
|
)
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
@ -37,10 +37,4 @@ import net.mamoe.mirai.console.data.PluginData
|
|||||||
* @see JAutoSavePluginData
|
* @see JAutoSavePluginData
|
||||||
* @see PluginConfig
|
* @see PluginConfig
|
||||||
*/
|
*/
|
||||||
public abstract class JAutoSavePluginConfig : AutoSavePluginConfig, PluginConfig {
|
public abstract class JAutoSavePluginConfig public constructor(saveName: String) : AutoSavePluginConfig(saveName), PluginConfig
|
||||||
@Deprecated("请手动指定保存名称. 此构造器将在 1.0.0 删除", level = DeprecationLevel.ERROR, replaceWith = ReplaceWith("JAutoSavePluginConfig(\"把我改成保存名称\")"))
|
|
||||||
@Suppress("DEPRECATION_ERROR")
|
|
||||||
public constructor() : super()
|
|
||||||
|
|
||||||
public constructor(saveName: String) : super(saveName)
|
|
||||||
}
|
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
@ -66,12 +66,7 @@ import kotlin.reflect.full.createType
|
|||||||
*
|
*
|
||||||
* @see PluginData
|
* @see PluginData
|
||||||
*/
|
*/
|
||||||
public abstract class JAutoSavePluginData : AutoSavePluginData, PluginConfig {
|
public abstract class JAutoSavePluginData public constructor(saveName: String) : AutoSavePluginData(saveName), PluginConfig {
|
||||||
@Deprecated("请手动指定保存名称. 此构造器将在 1.0.0 删除", level = DeprecationLevel.ERROR, replaceWith = ReplaceWith("JAutoSavePluginData(\"把我改成保存名称\")"))
|
|
||||||
@Suppress("DEPRECATION_ERROR")
|
|
||||||
public constructor() : super()
|
|
||||||
|
|
||||||
public constructor(saveName: String) : super(saveName)
|
|
||||||
|
|
||||||
//// region JPluginData_value_primitives CODEGEN ////
|
//// region JPluginData_value_primitives CODEGEN ////
|
||||||
|
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 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.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 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.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 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.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 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.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
@ -50,7 +50,8 @@ public interface InstanceExtensionPoint<T : InstanceExtension<*>> : ExtensionPoi
|
|||||||
public interface FunctionExtensionPoint<T : FunctionExtension> : ExtensionPoint<T>
|
public interface FunctionExtensionPoint<T : FunctionExtension> : ExtensionPoint<T>
|
||||||
|
|
||||||
|
|
||||||
public abstract class AbstractInstanceExtensionPoint<E : InstanceExtension<T>, T>(
|
public abstract class AbstractInstanceExtensionPoint<E : InstanceExtension<T>, T>
|
||||||
|
@ConsoleExperimentalApi constructor(
|
||||||
extensionType: KClass<E>,
|
extensionType: KClass<E>,
|
||||||
/**
|
/**
|
||||||
* 内建的实现列表.
|
* 内建的实现列表.
|
||||||
@ -59,7 +60,8 @@ public abstract class AbstractInstanceExtensionPoint<E : InstanceExtension<T>, T
|
|||||||
public vararg val builtinImplementations: E,
|
public vararg val builtinImplementations: E,
|
||||||
) : AbstractExtensionPoint<E>(extensionType)
|
) : AbstractExtensionPoint<E>(extensionType)
|
||||||
|
|
||||||
public abstract class AbstractSingletonExtensionPoint<E : SingletonExtension<T>, T>(
|
public abstract class AbstractSingletonExtensionPoint<E : SingletonExtension<T>, T>
|
||||||
|
@ConsoleExperimentalApi constructor(
|
||||||
extensionType: KClass<E>,
|
extensionType: KClass<E>,
|
||||||
/**
|
/**
|
||||||
* 内建的实现.
|
* 内建的实现.
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 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.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 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.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 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.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
@ -30,6 +30,6 @@ public interface CommandCallParserProvider : InstanceExtension<CommandCallParser
|
|||||||
public class CommandCallParserProviderImpl(override val instance: CommandCallParser) : CommandCallParserProvider
|
public class CommandCallParserProviderImpl(override val instance: CommandCallParser) : CommandCallParserProvider
|
||||||
|
|
||||||
@ExperimentalCommandDescriptors
|
@ExperimentalCommandDescriptors
|
||||||
public class CommandCallParserProviderImplLazy(instanceCalculator: () -> CommandCallParser) : CommandCallParserProvider {
|
public class CommandCallParserProviderImplLazy(initializer: () -> CommandCallParser) : CommandCallParserProvider {
|
||||||
override val instance: CommandCallParser by lazy(instanceCalculator)
|
override val instance: CommandCallParser by lazy(initializer)
|
||||||
}
|
}
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 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.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
@ -26,6 +26,6 @@ public interface CommandCallResolverProvider : InstanceExtension<CommandCallReso
|
|||||||
public class CommandCallResolverProviderImpl(override val instance: CommandCallResolver) : CommandCallResolverProvider
|
public class CommandCallResolverProviderImpl(override val instance: CommandCallResolver) : CommandCallResolverProvider
|
||||||
|
|
||||||
@ExperimentalCommandDescriptors
|
@ExperimentalCommandDescriptors
|
||||||
public class CommandCallResolverProviderImplLazy(instanceCalculator: () -> CommandCallResolver) : CommandCallResolverProvider {
|
public class CommandCallResolverProviderImplLazy(initializer: () -> CommandCallResolver) : CommandCallResolverProvider {
|
||||||
override val instance: CommandCallResolver by lazy(instanceCalculator)
|
override val instance: CommandCallResolver by lazy(initializer)
|
||||||
}
|
}
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 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.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 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.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 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.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
@ -24,10 +24,10 @@ public fun interface PostStartupExtension : FunctionExtension {
|
|||||||
/**
|
/**
|
||||||
* 将在 Console 主线程执行.
|
* 将在 Console 主线程执行.
|
||||||
*
|
*
|
||||||
* @throws Exception 所有抛出的 [Exception] 都会被捕获并包装为 [ExtensionException] 抛出, 并停止 [MiraiConsole]
|
|
||||||
*
|
|
||||||
* #### 内部实现细节
|
* #### 内部实现细节
|
||||||
* 在 [MiraiConsoleImplementationBridge.doStart] 所有 [MiraiConsoleImplementationBridge.phase] 执行完成后顺序调用.
|
* 在 [MiraiConsoleImplementationBridge.doStart] 所有 [MiraiConsoleImplementationBridge.phase] 执行完成后顺序调用.
|
||||||
|
*
|
||||||
|
* @throws Exception 所有抛出的 [Exception] 都会被捕获并包装为 [ExtensionException] 抛出, 并停止 [MiraiConsole]
|
||||||
*/
|
*/
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
public operator fun invoke()
|
public operator fun invoke()
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 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.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
@ -28,13 +28,16 @@ import kotlin.reflect.KClass
|
|||||||
* 如有多个 [SingletonExtensionSelector] 注册, 将会停止服务器.
|
* 如有多个 [SingletonExtensionSelector] 注册, 将会停止服务器.
|
||||||
*/
|
*/
|
||||||
public interface SingletonExtensionSelector : FunctionExtension {
|
public interface SingletonExtensionSelector : FunctionExtension {
|
||||||
|
/**
|
||||||
|
* 表示一个插件注册的 [Extension]
|
||||||
|
*/
|
||||||
public data class Registry<T : Extension>(
|
public data class Registry<T : Extension>(
|
||||||
val plugin: Plugin?,
|
val plugin: Plugin?,
|
||||||
val extension: T,
|
val extension: T,
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return null 表示使用 builtin
|
* @return `null` 表示使用 Console 内置的 [SingletonExtensionSelector]
|
||||||
*/
|
*/
|
||||||
public fun <T : Extension> selectSingleton(
|
public fun <T : Extension> selectSingleton(
|
||||||
extensionType: KClass<T>,
|
extensionType: KClass<T>,
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
@ -14,8 +14,8 @@ import java.time.Instant
|
|||||||
|
|
||||||
internal object MiraiConsoleBuildConstants { // auto-filled on build (task :mirai-console:fillBuildConstants)
|
internal object MiraiConsoleBuildConstants { // auto-filled on build (task :mirai-console:fillBuildConstants)
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
val buildDate: Instant = Instant.ofEpochSecond(1601134282)
|
val buildDate: Instant = Instant.ofEpochSecond(1604041264)
|
||||||
const val versionConst: String = "1.0-RC-dev-29"
|
const val versionConst: String = "1.0-RC-1"
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
val version: SemVersion = SemVersion(versionConst)
|
val version: SemVersion = SemVersion(versionConst)
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
@ -244,6 +244,9 @@ internal object MiraiConsoleImplementationBridge : CoroutineScope, MiraiConsoleI
|
|||||||
@DslMarker
|
@DslMarker
|
||||||
internal annotation class ILoveOmaeKumikoForever
|
internal annotation class ILoveOmaeKumikoForever
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表示一个初始化阶段, 无实际作用.
|
||||||
|
*/
|
||||||
@ILoveOmaeKumikoForever
|
@ILoveOmaeKumikoForever
|
||||||
private inline fun phase(block: () -> Unit) {
|
private inline fun phase(block: () -> Unit) {
|
||||||
contract {
|
contract {
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -1,3 +1,12 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
|
*
|
||||||
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
|
*
|
||||||
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
|
*/
|
||||||
|
|
||||||
package net.mamoe.mirai.console.internal.command
|
package net.mamoe.mirai.console.internal.command
|
||||||
|
|
||||||
import net.mamoe.mirai.console.command.*
|
import net.mamoe.mirai.console.command.*
|
||||||
@ -57,12 +66,12 @@ internal object SimpleCommandSubCommandAnnotationResolver :
|
|||||||
function.hasAnnotation<SimpleCommand.Handler>()
|
function.hasAnnotation<SimpleCommand.Handler>()
|
||||||
|
|
||||||
override fun getSubCommandNames(ownerCommand: Command, function: KFunction<*>): Array<out String> =
|
override fun getSubCommandNames(ownerCommand: Command, function: KFunction<*>): Array<out String> =
|
||||||
ownerCommand.secondaryNames
|
emptyArray()
|
||||||
|
|
||||||
override fun getAnnotatedName(ownerCommand: Command, parameter: KParameter): String? =
|
override fun getAnnotatedName(ownerCommand: Command, parameter: KParameter): String? =
|
||||||
parameter.findAnnotation<SimpleCommand.Name>()?.value
|
parameter.findAnnotation<SimpleCommand.Name>()?.value
|
||||||
|
|
||||||
override fun getDescription(ownerCommand: Command, function: KFunction<*>): String? =
|
override fun getDescription(ownerCommand: Command, function: KFunction<*>): String =
|
||||||
ownerCommand.description
|
ownerCommand.description
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,13 +153,13 @@ internal class CommandReflector(
|
|||||||
} else {
|
} else {
|
||||||
append(CommandManager.commandPrefix)
|
append(CommandManager.commandPrefix)
|
||||||
}
|
}
|
||||||
if (command is CompositeCommand) {
|
//if (command is CompositeCommand) {
|
||||||
append(command.primaryName)
|
append(command.primaryName)
|
||||||
append(" ")
|
append(" ")
|
||||||
}
|
//}
|
||||||
append(subcommand.valueParameters.joinToString(" ") { it.render() })
|
append(subcommand.valueParameters.joinToString(" ") { it.render() })
|
||||||
annotationResolver.getDescription(command, subcommand.originFunction).let { description ->
|
annotationResolver.getDescription(command, subcommand.originFunction)?.let { description ->
|
||||||
append(" ")
|
append(" # ")
|
||||||
append(description)
|
append(description)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -219,10 +228,16 @@ internal class CommandReflector(
|
|||||||
.onEach { it.checkExtensionReceiver() }
|
.onEach { it.checkExtensionReceiver() }
|
||||||
.onEach { it.checkModifiers() }
|
.onEach { it.checkModifiers() }
|
||||||
.onEach { it.checkNames() }
|
.onEach { it.checkNames() }
|
||||||
.map { function ->
|
.flatMap { function ->
|
||||||
|
val names = annotationResolver.getSubCommandNames(command, function)
|
||||||
|
if (names.isEmpty()) sequenceOf(createMapEntry(null, function))
|
||||||
|
else names.associateWith { function }.asSequence()
|
||||||
|
}
|
||||||
|
.map { (name, function) ->
|
||||||
|
|
||||||
val functionNameAsValueParameter =
|
val functionNameAsValueParameter =
|
||||||
annotationResolver.getSubCommandNames(command, function).mapIndexed { index, s -> createStringConstantParameter(index, s) }
|
name?.split(' ')?.mapIndexed { index, s -> createStringConstantParameter(index, s) }
|
||||||
|
.orEmpty()
|
||||||
|
|
||||||
val functionValueParameters =
|
val functionValueParameters =
|
||||||
function.valueParameters.associateBy { it.toUserDefinedCommandParameter() }
|
function.valueParameters.associateBy { it.toUserDefinedCommandParameter() }
|
||||||
@ -245,14 +260,32 @@ internal class CommandReflector(
|
|||||||
|
|
||||||
val instanceParameter = function.instanceParameter
|
val instanceParameter = function.instanceParameter
|
||||||
if (instanceParameter != null) {
|
if (instanceParameter != null) {
|
||||||
|
check(instanceParameter.type.classifierAsKClass().isInstance(command)) {
|
||||||
|
"Bad command call resolved. " +
|
||||||
|
"Function expects instance parameter ${instanceParameter.type} whereas actual instance is ${command::class}."
|
||||||
|
}
|
||||||
args[instanceParameter] = command
|
args[instanceParameter] = command
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val receiverParameter = function.extensionReceiverParameter
|
||||||
|
if (receiverParameter != null) {
|
||||||
|
check(receiverParameter.type.classifierAsKClass().isInstance(call.caller)) {
|
||||||
|
"Bad command call resolved. " +
|
||||||
|
"Function expects receiver parameter ${receiverParameter.type} whereas actual is ${call.caller::class}."
|
||||||
|
}
|
||||||
|
args[receiverParameter] = call.caller
|
||||||
|
}
|
||||||
function.callSuspendBy(args)
|
function.callSuspendBy(args)
|
||||||
}
|
}
|
||||||
}.toList()
|
}.toList()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun KParameter.toCommandReceiverParameter(): CommandReceiverParameter<out CommandSender>? {
|
private fun <K, V> createMapEntry(key: K, value: V) = object : Map.Entry<K, V> {
|
||||||
|
override val key: K get() = key
|
||||||
|
override val value: V get() = value
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun KParameter.toCommandReceiverParameter(): CommandReceiverParameter<out CommandSender> {
|
||||||
check(!this.isVararg) { "Receiver cannot be vararg." }
|
check(!this.isVararg) { "Receiver cannot be vararg." }
|
||||||
check(this.type.classifierAsKClass().isSubclassOf(CommandSender::class)) { "Receiver must be subclass of CommandSender" }
|
check(this.type.classifierAsKClass().isSubclassOf(CommandSender::class)) { "Receiver must be subclass of CommandSender" }
|
||||||
|
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
@ -58,6 +58,7 @@ internal fun Group.fuzzySearchMember(
|
|||||||
disambiguationRate: Double = 0.1,
|
disambiguationRate: Double = 0.1,
|
||||||
): List<Pair<Member, Double>> {
|
): List<Pair<Member, Double>> {
|
||||||
val candidates = (this.members + botAsMember)
|
val candidates = (this.members + botAsMember)
|
||||||
|
.asSequence()
|
||||||
.associateWith { it.nameCard.fuzzyMatchWith(nameCardTarget) }
|
.associateWith { it.nameCard.fuzzyMatchWith(nameCardTarget) }
|
||||||
.filter { it.value >= minRate }
|
.filter { it.value >= minRate }
|
||||||
.toList()
|
.toList()
|
||||||
@ -79,7 +80,7 @@ internal fun Group.fuzzySearchMember(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun Command.createOrFindCommandPermission(parent: Permission): Permission {
|
internal fun Command.findOrCreateCommandPermission(parent: Permission): Permission {
|
||||||
val id = owner.permissionId("command.$primaryName")
|
val id = owner.permissionId("command.$primaryName")
|
||||||
return PermissionService.INSTANCE[id] ?: PermissionService.INSTANCE.register(id, description, parent)
|
return PermissionService.INSTANCE[id] ?: PermissionService.INSTANCE.register(id, description, parent)
|
||||||
}
|
}
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -1,3 +1,12 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
|
*
|
||||||
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
|
*
|
||||||
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
|
*/
|
||||||
|
|
||||||
package net.mamoe.mirai.console.internal.data.builtins
|
package net.mamoe.mirai.console.internal.data.builtins
|
||||||
|
|
||||||
import net.mamoe.mirai.console.data.AutoSavePluginConfig
|
import net.mamoe.mirai.console.data.AutoSavePluginConfig
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 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.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -1,3 +1,12 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
|
*
|
||||||
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
|
*
|
||||||
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
|
*/
|
||||||
|
|
||||||
package net.mamoe.mirai.console.internal.extension
|
package net.mamoe.mirai.console.internal.extension
|
||||||
|
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 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.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 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.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 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.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
@ -23,7 +23,6 @@ import net.mamoe.mirai.console.plugin.loader.PluginLoadException
|
|||||||
import net.mamoe.mirai.console.util.CoroutineScopeUtils.childScope
|
import net.mamoe.mirai.console.util.CoroutineScopeUtils.childScope
|
||||||
import net.mamoe.mirai.utils.MiraiLogger
|
import net.mamoe.mirai.utils.MiraiLogger
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.net.URLClassLoader
|
|
||||||
import java.util.concurrent.ConcurrentHashMap
|
import java.util.concurrent.ConcurrentHashMap
|
||||||
|
|
||||||
internal object BuiltInJvmPluginLoaderImpl :
|
internal object BuiltInJvmPluginLoaderImpl :
|
||||||
@ -52,8 +51,22 @@ internal object BuiltInJvmPluginLoaderImpl :
|
|||||||
override fun Sequence<File>.extractPlugins(): List<JvmPlugin> {
|
override fun Sequence<File>.extractPlugins(): List<JvmPlugin> {
|
||||||
ensureActive()
|
ensureActive()
|
||||||
|
|
||||||
fun Sequence<Map.Entry<File, ClassLoader>>.findAllInstances(): Sequence<Map.Entry<File, JvmPlugin>> {
|
fun Sequence<Map.Entry<File, JvmPluginClassLoader>>.findAllInstances(): Sequence<Map.Entry<File, JvmPlugin>> {
|
||||||
return map { (f, pluginClassLoader) ->
|
return onEach { (_, pluginClassLoader) ->
|
||||||
|
val exportManagers = pluginClassLoader.findServices(
|
||||||
|
ExportManager::class
|
||||||
|
).loadAllServices()
|
||||||
|
if (exportManagers.isEmpty()) {
|
||||||
|
val rules = pluginClassLoader.getResourceAsStream("export-rules.txt")
|
||||||
|
if (rules == null)
|
||||||
|
pluginClassLoader.declaredFilter = StandardExportManagers.AllExported
|
||||||
|
else rules.bufferedReader(Charsets.UTF_8).useLines {
|
||||||
|
pluginClassLoader.declaredFilter = ExportManagerImpl.parse(it.iterator())
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pluginClassLoader.declaredFilter = exportManagers[0]
|
||||||
|
}
|
||||||
|
}.map { (f, pluginClassLoader) ->
|
||||||
f to pluginClassLoader.findServices(
|
f to pluginClassLoader.findServices(
|
||||||
JvmPlugin::class,
|
JvmPlugin::class,
|
||||||
KotlinPlugin::class,
|
KotlinPlugin::class,
|
||||||
@ -61,6 +74,7 @@ internal object BuiltInJvmPluginLoaderImpl :
|
|||||||
JavaPlugin::class
|
JavaPlugin::class
|
||||||
).loadAllServices()
|
).loadAllServices()
|
||||||
}.flatMap { (f, list) ->
|
}.flatMap { (f, list) ->
|
||||||
|
|
||||||
list.associateBy { f }.asSequence()
|
list.associateBy { f }.asSequence()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -68,7 +82,7 @@ internal object BuiltInJvmPluginLoaderImpl :
|
|||||||
val filePlugins = this.filterNot {
|
val filePlugins = this.filterNot {
|
||||||
pluginFileToInstanceMap.containsKey(it)
|
pluginFileToInstanceMap.containsKey(it)
|
||||||
}.associateWith {
|
}.associateWith {
|
||||||
JvmPluginClassLoader(it, MiraiConsole::class.java.classLoader)
|
JvmPluginClassLoader(it, MiraiConsole::class.java.classLoader, classLoaders)
|
||||||
}.onEach { (_, classLoader) ->
|
}.onEach { (_, classLoader) ->
|
||||||
classLoaders.add(classLoader)
|
classLoaders.add(classLoader)
|
||||||
}.asSequence().findAllInstances().onEach {
|
}.asSequence().findAllInstances().onEach {
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
*
|
*
|
||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
|
*
|
||||||
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||||
|
*
|
||||||
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.mamoe.mirai.console.internal.plugin
|
||||||
|
|
||||||
|
import net.mamoe.mirai.console.plugin.jvm.ExportManager
|
||||||
|
|
||||||
|
internal class ExportManagerImpl(
|
||||||
|
private val rules: List<(String) -> Boolean?>
|
||||||
|
) : ExportManager {
|
||||||
|
|
||||||
|
override fun isExported(className: String): Boolean {
|
||||||
|
rules.forEach {
|
||||||
|
val result = it(className)
|
||||||
|
if (result != null) return@isExported result
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
@JvmStatic
|
||||||
|
fun parse(lines: Iterator<String>): ExportManagerImpl {
|
||||||
|
fun Boolean.without(value: Boolean) = if (this == value) null else this
|
||||||
|
|
||||||
|
val rules = ArrayList<(String) -> Boolean?>()
|
||||||
|
lines.asSequence().map { it.trim() }.filter { it.isNotBlank() }.filterNot {
|
||||||
|
it[0] == '#'
|
||||||
|
}.forEach { line ->
|
||||||
|
val command = line.substringBefore(' ')
|
||||||
|
val argument = line.substringAfter(' ', missingDelimiterValue = "").trim()
|
||||||
|
val argumentPackage = "$argument."
|
||||||
|
|
||||||
|
when (command) {
|
||||||
|
"exports" -> rules.add {
|
||||||
|
(it == argument || it.startsWith(argumentPackage)).without(false)
|
||||||
|
}
|
||||||
|
"protects" -> rules.add {
|
||||||
|
if (it == argument || it.startsWith(argumentPackage))
|
||||||
|
false
|
||||||
|
else null
|
||||||
|
}
|
||||||
|
"export-all", "export-plugin", "export-system" -> rules.add { true }
|
||||||
|
"protect-all", "protect-plugin", "protect-system" -> rules.add { false }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ExportManagerImpl(rules)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user