diff --git a/bukkit/src/main/java/co/aikar/commands/BukkitRootCommand.java b/bukkit/src/main/java/co/aikar/commands/BukkitRootCommand.java index 8c0ce9d5..45fe7301 100644 --- a/bukkit/src/main/java/co/aikar/commands/BukkitRootCommand.java +++ b/bukkit/src/main/java/co/aikar/commands/BukkitRootCommand.java @@ -46,6 +46,22 @@ public class BukkitRootCommand extends Command implements RootCommand { this.name = name; } + @Override + public String getDescription() { + RegisteredCommand command = getDefaultRegisteredCommand(); + + if (command != null && !command.getHelpText().isEmpty()) { + return command.getHelpText(); + } + if (command != null && command.scope.description != null) { + return command.scope.description; + } + if (defCommand.description != null) { + return defCommand.description; + } + return super.getDescription(); + } + @Override public String getCommandName() { return name; diff --git a/core/src/main/java/co/aikar/commands/BaseCommand.java b/core/src/main/java/co/aikar/commands/BaseCommand.java index 533a7d8e..788a7631 100644 --- a/core/src/main/java/co/aikar/commands/BaseCommand.java +++ b/core/src/main/java/co/aikar/commands/BaseCommand.java @@ -30,6 +30,7 @@ import co.aikar.commands.annotation.CommandAlias; import co.aikar.commands.annotation.CommandPermission; import co.aikar.commands.annotation.Conditions; import co.aikar.commands.annotation.Default; +import co.aikar.commands.annotation.Description; import co.aikar.commands.annotation.HelpCommand; import co.aikar.commands.annotation.PreCommand; import co.aikar.commands.annotation.Subcommand; @@ -247,7 +248,7 @@ public abstract class BaseCommand { this.commandName = cmd != null ? cmd : self.getSimpleName().toLowerCase(); this.permission = annotations.getAnnotationValue(self, CommandPermission.class, Annotations.REPLACEMENTS); - this.description = this.commandName + " commands"; + this.description = annotations.getAnnotationValue(self, Description.class, Annotations.NO_EMPTY | Annotations.REPLACEMENTS); this.parentSubcommand = getParentSubcommand(self); this.conditions = annotations.getAnnotationValue(self, Conditions.class, Annotations.REPLACEMENTS | Annotations.NO_EMPTY); diff --git a/core/src/main/java/co/aikar/commands/annotation/Description.java b/core/src/main/java/co/aikar/commands/annotation/Description.java index 96aa234e..5d690cdf 100644 --- a/core/src/main/java/co/aikar/commands/annotation/Description.java +++ b/core/src/main/java/co/aikar/commands/annotation/Description.java @@ -33,7 +33,7 @@ import java.lang.annotation.Target; * This is used in the help menus. */ @Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.METHOD, ElementType.PARAMETER}) +@Target({ElementType.METHOD, ElementType.PARAMETER, ElementType.TYPE}) public @interface Description { String value(); } diff --git a/example/src/main/java/co/aikar/acfexample/SomeCommand.java b/example/src/main/java/co/aikar/acfexample/SomeCommand.java index 72118064..50cbcc9e 100644 --- a/example/src/main/java/co/aikar/acfexample/SomeCommand.java +++ b/example/src/main/java/co/aikar/acfexample/SomeCommand.java @@ -30,6 +30,7 @@ import co.aikar.commands.annotation.CommandPermission; import co.aikar.commands.annotation.Conditions; import co.aikar.commands.annotation.Default; import co.aikar.commands.annotation.Dependency; +import co.aikar.commands.annotation.Description; import co.aikar.commands.annotation.Optional; import co.aikar.commands.annotation.Subcommand; import co.aikar.commands.annotation.Values; @@ -40,6 +41,7 @@ import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; @CommandAlias("acf|somecommand|sc|somcom") +@Description("Some ACF Command") public class SomeCommand extends BaseCommand { { @@ -91,6 +93,7 @@ public class SomeCommand extends BaseCommand { @Subcommand("admin") @CommandPermission("some.perm") @CommandAlias("acfadmin|acfa") + @Description("Test Admin Commands") public void onAdminCommand(Player player) { player.sendMessage("You got permission!"); } @@ -123,6 +126,7 @@ public class SomeCommand extends BaseCommand { // Then the enum will also pick up default of its values even though it was left off of the completion @Subcommand("completions") @CommandAlias("acfcompletions|acfc") + @Description("Test Completions") @CommandCompletion("* * @test foo1|foo2|foo3") public void onTestCompletion(CommandSender sender, OnlinePlayer player, World world, String test, String foo1, TestEnum e) { sender.sendMessage("You got " + player.getPlayer().getName() + " - " + world.getName() + " - " + test + " - " + foo1 + " - " + e.name());