drink icon indicating copy to clipboard operation
drink copied to clipboard

Add option to disable tab completion for specific commands

Open itspinger opened this issue 2 years ago • 0 comments

This pull allows users to utilize the @HideCommand annotation.

When this annotation is applied to a DrinkCommand method, it will be removed from tab completion, and will not be displayed when doing / help. This is useful when we want to hide certain commands from players.

For example, when we want to hide a reload command, it would look like this:

package net.pinger.hynick.commands;

import com.jonahseguin.drink.annotation.Command;
import com.jonahseguin.drink.annotation.HideCommand;
import com.jonahseguin.drink.annotation.Require;
import com.jonahseguin.drink.annotation.Sender;
import net.pinger.hynick.SpigotHynickPlugin;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;

public class ReloadCommand {

    private final SpigotHynickPlugin plugin;

    public ReloadCommand(SpigotHynickPlugin plugin) {
        this.plugin = plugin;
    }

    @Command(name = "reload", usage = "reload", desc = "Reload configuration files of this plugin")
    @Require("hynick.reload")
    @HideCommand
    public void reload(@Sender CommandSender sender) {
        this.plugin.getFeatureManager().reload();
        sender.sendMessage(ChatColor.AQUA + "[Hynick] Reloaded configuration files.");
    }
}

itspinger avatar Oct 03 '22 17:10 itspinger