From 95fe4577be4992ded9466c4a52492b54a3a668c7 Mon Sep 17 00:00:00 2001 From: MiniDigger Date: Fri, 20 Apr 2018 17:28:22 +0200 Subject: [PATCH] add a new annotation to hide commands from tabcompletion and help (#124) * add a new annotation to hide commands from tabcompletion and help (implements #123) * do the annotation lookup once --- .../java/co/aikar/commands/BaseCommand.java | 4 +++ .../java/co/aikar/commands/CommandHelp.java | 3 +- .../co/aikar/commands/RegisteredCommand.java | 6 +++- .../co/aikar/commands/annotation/Private.java | 34 +++++++++++++++++++ .../java/co/aikar/acfexample/ACFExample.java | 3 ++ .../acfexample/SomeCommand_ExtraSubs.java | 14 ++++++++ 6 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 core/src/main/java/co/aikar/commands/annotation/Private.java diff --git a/core/src/main/java/co/aikar/commands/BaseCommand.java b/core/src/main/java/co/aikar/commands/BaseCommand.java index 9b2502d3..a1231bf0 100644 --- a/core/src/main/java/co/aikar/commands/BaseCommand.java +++ b/core/src/main/java/co/aikar/commands/BaseCommand.java @@ -518,6 +518,10 @@ public abstract class BaseCommand { continue; } + if(value.isPrivate){ + continue; + } + String[] split = ACFPatterns.SPACE.split(value.prefSubCommand); cmds.add(split[cmdIndex]); } diff --git a/core/src/main/java/co/aikar/commands/CommandHelp.java b/core/src/main/java/co/aikar/commands/CommandHelp.java index 1d91aab4..c5b4fef5 100644 --- a/core/src/main/java/co/aikar/commands/CommandHelp.java +++ b/core/src/main/java/co/aikar/commands/CommandHelp.java @@ -65,7 +65,8 @@ public class CommandHelp { } RegisteredCommand regCommand = e.getValue(); - if (regCommand.hasPermission(issuer) && !seen.contains(regCommand)) { + + if (!regCommand.isPrivate && regCommand.hasPermission(issuer) && !seen.contains(regCommand)) { this.helpEntries.add(new HelpEntry(this, regCommand)); seen.add(regCommand); } diff --git a/core/src/main/java/co/aikar/commands/RegisteredCommand.java b/core/src/main/java/co/aikar/commands/RegisteredCommand.java index 10dd076d..225c8c9f 100644 --- a/core/src/main/java/co/aikar/commands/RegisteredCommand.java +++ b/core/src/main/java/co/aikar/commands/RegisteredCommand.java @@ -29,6 +29,7 @@ import co.aikar.commands.annotation.CommandPermission; import co.aikar.commands.annotation.Conditions; import co.aikar.commands.annotation.Description; import co.aikar.commands.annotation.HelpSearchTags; +import co.aikar.commands.annotation.Private; import co.aikar.commands.annotation.Syntax; import co.aikar.commands.contexts.ContextResolver; import com.google.common.collect.ImmutableSet; @@ -64,6 +65,8 @@ public class RegisteredCommand