mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-27 00:30:17 +08:00
Fix string constant arguments
This commit is contained in:
parent
71c744c429
commit
b6794a8826
@ -18,6 +18,7 @@ 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.KType
|
import kotlin.reflect.KType
|
||||||
import kotlin.reflect.full.isSubclassOf
|
import kotlin.reflect.full.isSubclassOf
|
||||||
@ -144,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?,
|
||||||
@ -184,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.type.isSubtypeOf(expectingType) && 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>()
|
||||||
|
Loading…
Reference in New Issue
Block a user