Skip to content
Permalink
Browse files

Implement Bukkit Description for /help

  • Loading branch information...
aikar committed Mar 15, 2019
1 parent e9857cb commit 9c1521a4561c8f36790d945ab2e4b26b54044e75
@@ -46,6 +46,22 @@
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;
@@ -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.Description;
import co.aikar.commands.annotation.HelpCommand;
import co.aikar.commands.annotation.PreCommand;
import co.aikar.commands.annotation.Subcommand;
@@ -247,7 +248,7 @@ private void onRegister(CommandManager manager, String cmd) {

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);

@@ -33,7 +33,7 @@
* 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();
}
@@ -30,6 +30,7 @@
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.plugin.Plugin;

@CommandAlias("acf|somecommand|sc|somcom")
@Description("Some ACF Command")
public class SomeCommand extends BaseCommand {

{
@@ -91,6 +93,7 @@ public void onCondition(CommandSender sender) {
@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 void onTestDefault(CommandSender sender, @Default("Unknown User") String
// 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());

0 comments on commit 9c1521a

Please sign in to comment.
You can’t perform that action at this time.