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 137f7467..55426ec3 100644 --- a/cloud-annotations/src/main/java/cloud/commandframework/annotations/AnnotationParser.java +++ b/cloud-annotations/src/main/java/cloud/commandframework/annotations/AnnotationParser.java @@ -203,8 +203,11 @@ public final class AnnotationParser { break; } } - /* Decorate command data */ - builder = builder.withPermission(commandMethod.permission()); + + if (method.isAnnotationPresent(CommandPermission.class)) { + builder = builder.withPermission(method.getAnnotation(CommandPermission.class).value()); + } + if (commandMethod.requiredSender() != Object.class) { builder = builder.withSenderType(commandMethod.requiredSender()); } else if (senderType != null) { diff --git a/cloud-annotations/src/main/java/cloud/commandframework/annotations/CommandMethod.java b/cloud-annotations/src/main/java/cloud/commandframework/annotations/CommandMethod.java index c38903f1..69baf09d 100644 --- a/cloud-annotations/src/main/java/cloud/commandframework/annotations/CommandMethod.java +++ b/cloud-annotations/src/main/java/cloud/commandframework/annotations/CommandMethod.java @@ -42,13 +42,6 @@ public @interface CommandMethod { */ String value(); - /** - * The command permission node - * - * @return Command permission node - */ - String permission() default ""; - /** * The required sender * diff --git a/cloud-annotations/src/main/java/cloud/commandframework/annotations/CommandPermission.java b/cloud-annotations/src/main/java/cloud/commandframework/annotations/CommandPermission.java new file mode 100644 index 00000000..0cf82cd7 --- /dev/null +++ b/cloud-annotations/src/main/java/cloud/commandframework/annotations/CommandPermission.java @@ -0,0 +1,45 @@ +// +// MIT License +// +// Copyright (c) 2020 Alexander Söderberg & Contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +// +package cloud.commandframework.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Equivalent to {@link cloud.commandframework.Command.Builder#withPermission(String)} + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +public @interface CommandPermission { + + /** + * Get the command permission + * + * @return Command permission + */ + String value() default ""; + +}