Skip to content

Commit

Permalink
fix: 修复@Result注解无法被正确处理
Browse files Browse the repository at this point in the history
  • Loading branch information
huanmeng-qwq committed Aug 27, 2024
1 parent d378413 commit 31290e7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,9 @@

import dev.rollczi.litecommands.LiteCommandsBuilder;
import dev.rollczi.litecommands.LiteCommandsFactory;
import dev.rollczi.litecommands.LiteCommandsInternal;
import dev.rollczi.litecommands.extension.annotations.LiteAnnotationsProcessorExtension;
import dev.rollczi.litecommands.handler.result.ResultHandler;
import dev.rollczi.litecommands.handler.result.ResultHandlerChain;
import dev.rollczi.litecommands.invocation.Invocation;
import dev.rollczi.litecommands.message.InvokedMessage;
import dev.rollczi.litecommands.processor.LiteBuilderProcessor;
import snw.jkook.Core;
import snw.jkook.HttpAPI;
import snw.jkook.command.CommandException;
import snw.jkook.command.CommandSender;
import snw.jkook.command.ConsoleCommandSender;
import snw.jkook.entity.CustomEmoji;
Expand Down Expand Up @@ -80,8 +73,8 @@ public static <B extends LiteCommandsBuilder<CommandSender, LiteKookSettings, B>
.bind(Plugin.class, () -> plugin)
.bindUnsafe(plugin.getClass(), () -> plugin)
.bind(KBCClient.class, () -> client)
.extension(processorExtension)
.validatorGlobal(new ResultTypeValidator())
.extension(processorExtension)
.context(Message.class, new KookMessageContextual())
.context(User.class, new KookOnlyUserContextual<>("只有用户才能执行该命令"))
.context(ConsoleCommandSender.class, new KookOnlyConsoleContextual<>("只有后台才能执行该命令"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public ResultAnnotationResolver(Logger logger) {

@Override
public AnnotationInvoker<SENDER> process(AnnotationInvoker<SENDER> invoker) {
return invoker.on(Result.class, (annotation, metaHolder) -> {
return invoker.onExecutorStructure(Result.class, (annotation, builder, executorProvider) -> {
ResultType resultTypes = annotation.value();
if (!Objects.equals(ResultType.class, annotation.custom())) {
try {
Expand All @@ -47,7 +47,7 @@ public AnnotationInvoker<SENDER> process(AnnotationInvoker<SENDER> invoker) {
}
}
if (resultTypes == ResultTypes.DEFAULT) return;
metaHolder.meta().put(ResultType.RESULT_TYPE_KEY, resultTypes);
builder.meta().put(ResultType.RESULT_TYPE_KEY, resultTypes);
});
}

Expand Down

0 comments on commit 31290e7

Please sign in to comment.