From 00f90fe3aca0a947370225241437809a3f291078 Mon Sep 17 00:00:00 2001 From: "jiahua.liu" Date: Tue, 26 May 2020 16:59:15 +0800 Subject: [PATCH] Composite Command Test pass --- .../net/mamoe/mirai/console/command/Command.kt | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/Command.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/Command.kt index 4ec428e7b..609ae4cf9 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/Command.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/Command.kt @@ -102,8 +102,7 @@ abstract class CompositeCommand @JvmOverloads constructor( "", CommandPermission.Default, onCommand = block { sender: CommandSender, args: Array -> - println("default finally got args: ${args.joinToString()}") - true + false//not supported yet } ) } @@ -114,17 +113,8 @@ abstract class CompositeCommand @JvmOverloads constructor( this@CompositeCommand::class.declaredFunctions.filter { it.hasAnnotation() }.map { function -> - function.parameters.forEach { - println(it) - println(it.type.classifier) - println() - println() - } - val notStatic = function.findAnnotation()==null - val overridePermission = function.findAnnotation()//optional - val subDescription = function.findAnnotation()?.description?:"no description available" if((function.returnType.classifier as? KClass<*>)?.isSubclassOf(Boolean::class) != true){ @@ -132,7 +122,6 @@ abstract class CompositeCommand @JvmOverloads constructor( } val parameter = function.parameters.toMutableList() - if (parameter.isEmpty()){ throw IllegalParameterException("First parameter (receiver for kotlin) for sub commend " + function.name + " from " + this.getPrimaryName() + " should be ") } @@ -170,7 +159,7 @@ abstract class CompositeCommand @JvmOverloads constructor( } val argName = it.findAnnotation()?.name?:it.name?:"unknown" - buildUsage.append("<").append(argName).append("> ").append(" ") + buildUsage.append("<").append(argName).append("> ") CommandParam( argName, (it.type.classifier as? KClass<*>)?: throw IllegalParameterException("unsolved type reference from param " + it.name + " in " + function.name + " from " + this.getPrimaryName()))