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
This commit is contained in:
MiniDigger
2018-04-20 17:28:22 +02:00
committed by Daniel Ennis
parent 2d45e03dae
commit 95fe4577be
6 changed files with 62 additions and 2 deletions
@@ -44,6 +44,9 @@ public final class ACFExample extends JavaPlugin {
// 1: Create Command Manager for your respective platform
commandManager = new BukkitCommandManager(this);
// optional: enable unstable api to use help
commandManager.enableUnstableAPI("help");
// 2: Setup some replacement values that may be used inside of the annotations dynamically.
commandManager.getCommandReplacements().addReplacements(
// key - value
@@ -24,8 +24,11 @@
package co.aikar.acfexample;
import co.aikar.commands.BaseCommand;
import co.aikar.commands.CommandHelp;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandCompletion;
import co.aikar.commands.annotation.HelpCommand;
import co.aikar.commands.annotation.Private;
import co.aikar.commands.annotation.Subcommand;
import org.bukkit.command.CommandSender;
@@ -37,4 +40,15 @@ public class SomeCommand_ExtraSubs extends BaseCommand {
public void onTestSub2(CommandSender sender, String hi) {
sender.sendMessage(hi);
}
@Private
@Subcommand("testsub private")
public void privateSub(CommandSender sender){
sender.sendMessage("Am a sneaky ninja!");
}
@HelpCommand
public void help(CommandSender sender, CommandHelp help){
help.showHelp();
}
}