From 3df3560d91de673ae74ef20e5ec588ae536561e3 Mon Sep 17 00:00:00 2001 From: Jason <11360596+jpenilla@users.noreply.github.com> Date: Tue, 28 Sep 2021 04:10:36 -0500 Subject: [PATCH] annotations: Also apply builder modifiers from class (#303) --- CHANGELOG.md | 1 + .../commandframework/annotations/AnnotationParser.java | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fac41c2..d729c56b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Added `executeFuture` to `CommandExecutionHandler` which is now used internally. By default, this delegates to the old `execute` method +- Annotations: Apply builder modifiers from class annotations ([#303](https://github.com/Incendo/cloud/pull/303)) ### Fixed - Bukkit: Permission checking and syntax string for Bukkit '/help' command diff --git a/cloud-annotations/src/main/java/cloud/commandframework/annotations/AnnotationParser.java b/cloud-annotations/src/main/java/cloud/commandframework/annotations/AnnotationParser.java index a78ffbd2..dccc0054 100644 --- a/cloud-annotations/src/main/java/cloud/commandframework/annotations/AnnotationParser.java +++ b/cloud-annotations/src/main/java/cloud/commandframework/annotations/AnnotationParser.java @@ -522,7 +522,10 @@ public final class AnnotationParser { for (final CommandFlag flag : flags) { builder = builder.flag(flag); } - for (final Annotation annotation : method.getDeclaredAnnotations()) { + + /* Apply builder modifiers */ + for (final Annotation annotation + : AnnotationAccessor.of(classAnnotations, AnnotationAccessor.of(method)).annotations()) { @SuppressWarnings("rawtypes") final BiFunction builderModifier = this.builderModifiers.get(annotation.annotationType()); if (builderModifier == null) { @@ -530,6 +533,7 @@ public final class AnnotationParser { } builder = (Command.Builder) builderModifier.apply(annotation, builder); } + /* Construct and register the command */ final Command builtCommand = builder.build(); commands.add(builtCommand);