> For the complete documentation index, see [llms.txt](https://kynosdeveloping.gitbook.io/kynosdeveloping/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kynosdeveloping.gitbook.io/kynosdeveloping/kynoslib/command-framework.md).

# 🎮 Command Framework

KynosLib features an annotation-driven command management system via **`KynosCommand`** that completely eliminates the need for complex `if-else` argument checking and manual permission validation.

#### ✨ Key Features

* 🎯 **Annotation Routing**: Sub-commands are declared using `@SubCommand` directly on top of your methods.
* 🛡️ **Automated Checks**: The framework automatically handles `permission` checks and restricts console execution if `playerOnly = true` is set.
* 🔍 **Smart Tab Completion**: Integrates with custom tab completers to dynamically filter suggestions based on what the sender is allowed to see.

***

#### 💡 Code Example: Creating a Framework Command

To create a new command, extend `KynosCommand` and define your sub-commands using the annotations:

```java
public class MyCustomCommand extends KynosCommand {

    public MyCustomCommand(KynosLib plugin) {
        super(plugin, "mycommand");
    }

    // This runs when a player types just /mycommand (no arguments)
    @Override
    protected boolean execute(CommandSender sender, String[] args) {
        sender.sendMessage("§eWelcome to the main command interface!");
        return true;
    }

    // This runs automatically when typing /mycommand open
    @SubCommand(name = "open", permission = "myplugin.use.gui", playerOnly = true)
    public boolean onOpenMenu(CommandSender sender, String[] args) {
        Player player = (Player) sender;
        player.sendMessage("§aOpening your custom framework menu...");
        return true;
    }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kynosdeveloping.gitbook.io/kynosdeveloping/kynoslib/command-framework.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
