From 33443a63ad4bfae7633a2a5cd4e60eeb51b2b538 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20S=C3=B6derberg?= <4096670+Citymonstret@users.noreply.github.com> Date: Sat, 13 Jan 2024 20:00:10 +0100 Subject: [PATCH] chore: remove "hidden" functionality (#635) This isn't used anywhere. The other alternative is that we do make use of this, but then we need to decide _where_ the command is hidden. In help menus? In syntax strings? Suggestions? --- .../annotations/AnnotationParser.java | 13 ++----- .../commandframework/annotations/Hidden.java | 39 ------------------- .../annotations/ProxiedBy.java | 7 ---- .../java/cloud/commandframework/Command.java | 19 --------- .../commandframework/meta/CommandMeta.java | 6 --- .../kotlin/MutableCommandBuilder.kt | 11 ------ 6 files changed, 3 insertions(+), 92 deletions(-) delete mode 100644 cloud-annotations/src/main/java/cloud/commandframework/annotations/Hidden.java 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 29fdabbc3..4bce85996 100644 --- a/cloud-annotations/src/main/java/cloud/commandframework/annotations/AnnotationParser.java +++ b/cloud-annotations/src/main/java/cloud/commandframework/annotations/AnnotationParser.java @@ -964,10 +964,6 @@ private void parseParsers(final @NonNull T instance) { } catch (final Exception e) { throw new RuntimeException("Failed to construct command execution handler", e); } - /* Check if the command should be hidden */ - if (methodOrClassHasAnnotation(method, Hidden.class)) { - builder = builder.hidden(); - } /* Apply flags */ for (final CommandFlag flag : flags) { builder = builder.flag(flag); @@ -1016,12 +1012,9 @@ private void parseParsers(final @NonNull T instance) { if (proxy.contains(" ")) { throw new IllegalArgumentException("@ProxiedBy proxies may only contain single literals"); } - cloud.commandframework.Command.Builder proxyBuilder = this.manager.commandBuilder(proxy, command.commandMeta()) - .proxies(command); - if (proxyAnnotation.hidden()) { - proxyBuilder = proxyBuilder.hidden(); - } - return proxyBuilder.build(); + return this.manager.commandBuilder(proxy, command.commandMeta()) + .proxies(command) + .build(); } private @NonNull SyntaxFragment findSyntaxFragment( diff --git a/cloud-annotations/src/main/java/cloud/commandframework/annotations/Hidden.java b/cloud-annotations/src/main/java/cloud/commandframework/annotations/Hidden.java deleted file mode 100644 index 858368926..000000000 --- a/cloud-annotations/src/main/java/cloud/commandframework/annotations/Hidden.java +++ /dev/null @@ -1,39 +0,0 @@ -// -// MIT License -// -// Copyright (c) 2024 Incendo -// -// 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 cloud.commandframework.Command; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Indicates that the command should be hidden. Similar to {@link Command.Builder#hidden()} - */ -@Target({ElementType.METHOD, ElementType.TYPE}) -@Retention(RetentionPolicy.RUNTIME) -public @interface Hidden { - -} diff --git a/cloud-annotations/src/main/java/cloud/commandframework/annotations/ProxiedBy.java b/cloud-annotations/src/main/java/cloud/commandframework/annotations/ProxiedBy.java index c4347c40d..ebe3ef35e 100644 --- a/cloud-annotations/src/main/java/cloud/commandframework/annotations/ProxiedBy.java +++ b/cloud-annotations/src/main/java/cloud/commandframework/annotations/ProxiedBy.java @@ -44,11 +44,4 @@ * @return Proxy syntax */ @NonNull String value(); - - /** - * Whether or not the proxying command should be {@link Hidden} - * - * @return {@code true} if the proxying command should be hidden, {@code false} if not - */ - boolean hidden() default false; } diff --git a/cloud-core/src/main/java/cloud/commandframework/Command.java b/cloud-core/src/main/java/cloud/commandframework/Command.java index a75d38094..c42837089 100644 --- a/cloud-core/src/main/java/cloud/commandframework/Command.java +++ b/cloud-core/src/main/java/cloud/commandframework/Command.java @@ -404,15 +404,6 @@ public final String toString() { return build.substring(0, build.length() - 1); } - /** - * Returns whether the command is hidden. - * - * @return {@code true} if the command is hidden, {@code false} if not - */ - public boolean isHidden() { - return this.commandMeta().getOrDefault(CommandMeta.HIDDEN, false); - } - /** * Builder for {@link Command} instances. The builder is immutable, and each @@ -2261,16 +2252,6 @@ private Builder( return builder.handler(command.commandExecutionHandler); } - /** - * Indicates that the command should be hidden from help menus - * and other places where commands are exposed to users. - * - * @return new builder instance that indicates that the constructed command should be hidden - */ - public @NonNull Builder hidden() { - return this.meta(CommandMeta.HIDDEN, true); - } - /** * Registers a new command flag. * diff --git a/cloud-core/src/main/java/cloud/commandframework/meta/CommandMeta.java b/cloud-core/src/main/java/cloud/commandframework/meta/CommandMeta.java index 465e8494d..b8b81276b 100644 --- a/cloud-core/src/main/java/cloud/commandframework/meta/CommandMeta.java +++ b/cloud-core/src/main/java/cloud/commandframework/meta/CommandMeta.java @@ -24,7 +24,6 @@ package cloud.commandframework.meta; import cloud.commandframework.Command; -import cloud.commandframework.keys.CloudKey; import cloud.commandframework.keys.CloudKeyContainer; import org.apiguardian.api.API; import org.checkerframework.checker.nullness.qual.NonNull; @@ -38,11 +37,6 @@ @API(status = API.Status.STABLE) public abstract class CommandMeta implements CloudKeyContainer { - public static final CloudKey HIDDEN = CloudKey.of( - "cloud:hidden", - Boolean.class - ); - /** * Create a new simple command meta-builder * diff --git a/cloud-kotlin/cloud-kotlin-extensions/src/main/kotlin/cloud/commandframework/kotlin/MutableCommandBuilder.kt b/cloud-kotlin/cloud-kotlin-extensions/src/main/kotlin/cloud/commandframework/kotlin/MutableCommandBuilder.kt index 16e0011d1..0df3dcd37 100644 --- a/cloud-kotlin/cloud-kotlin-extensions/src/main/kotlin/cloud/commandframework/kotlin/MutableCommandBuilder.kt +++ b/cloud-kotlin/cloud-kotlin-extensions/src/main/kotlin/cloud/commandframework/kotlin/MutableCommandBuilder.kt @@ -34,7 +34,6 @@ import cloud.commandframework.execution.CommandExecutionHandler import cloud.commandframework.keys.CloudKey import cloud.commandframework.kotlin.extension.command import cloud.commandframework.kotlin.extension.senderType -import cloud.commandframework.meta.CommandMeta import cloud.commandframework.permission.Permission import kotlin.reflect.KClass @@ -280,16 +279,6 @@ public class MutableCommandBuilder( it.commandDescription(commandDescription) } - /** - * Set the [CommandMeta.HIDDEN] meta for this command - * - * @param hidden whether this command should be hidden - * @return this mutable builder - * @since 1.3.0 - */ - public fun hidden(hidden: Boolean = true): MutableCommandBuilder = - meta(CommandMeta.HIDDEN, hidden) - /** * Specify a required sender type *