11# CommandsAPI
22
3- CommandsAPI is a powerful and flexible Java library for creating and managing commands in Bukkit/Spigot plugins. It provides a robust framework for handling command arguments, permissions, subcommands, and auto-completion, making it easier to build complex command structures in your Minecraft plugins.
3+ ** CommandsAPI** is a modular, extensible Java library for building robust, typed command systems across multiple platforms such as ** Spigot** and ** Velocity** .
4+ As of version ` 4.0.0 ` , all core logic has been extracted into a dedicated ` core ` module, enabling seamless multi-platform support.
45
5- ## Features
6+ ---
7+
8+ ## ✨ Features
9+
10+ * ✅ ** Multi-Platform Support** (Spigot, Velocity, etc.)
11+ * ✅ ** Typed Argument Parsing** with validation
12+ * ✅ ** Custom Argument Converters**
13+ * ✅ ** Subcommands & Hierarchical Command Trees**
14+ * ✅ ** Tab Completion Support**
15+ * ✅ ** Permission & Context Requirements**
16+ * ✅ ** Optional and Infinite Arguments**
17+ * ✅ ** Auto-Generated Usage Help**
18+ * ✅ ** Lightweight, Fast, and Fully Extensible**
19+
20+ ---
21+
22+ ## 🧱 Project Structure
23+
24+ ```
25+ traqueur-dev-commandsapi/
26+ ├── core/ # Platform-agnostic command logic
27+ ├── spigot/ # Spigot implementation
28+ ├── <platform>-test-plugin/ # The test plugin for the specified platform
29+ └── velocity/ # Velocity implementation
30+ ```
31+
32+ ---
633
7- - ** Customizable Commands:** Easily create commands with custom arguments, descriptions, usage, and permissions.
8- - ** Subcommands Support:** Organize your commands with subcommands and handle complex command structures effortlessly.
9- - ** Argument Handling:** Support for various argument types including custom types and auto-completion for a better user experience.
10- - ** Permissions and Aliases:** Define permissions and aliases for your commands to control access and provide alternative command names.
11- - ** In-Game/Console Command Support:** Specify whether a command can only be executed in-game or from the console.
12- - ** Commands Requirements:** Set requirements for commands to be executed, use specific conditions like in specific world.
34+ ## 🚀 Getting Started
1335
14- ## Getting Started
36+ ### ✅ Requirements
1537
16- ### Prerequisites
38+ * Java 21+
39+ * A supported Minecraft platform (e.g., Spigot or Velocity)
40+ * Build tool (Gradle/Maven) with JitPack
1741
18- - ** Java 21** or higher
19- - ** Paper/Spigot API** - Compatible with various Minecraft server versions
20- - ** CommandsAPI Library** - Add it to your project dependencies
42+ ---
2143
22- ### Installation
44+ ## 📦 Installation
2345
24- To use CommandsAPI in your project, add the dependency to your build configuration. For Maven, include:
46+ ### Gradle
2547
26- #### For Gradle include
2748``` groovy
2849repositories {
2950 maven { url 'https://jitpack.io' }
3051}
52+
3153dependencies {
32- implementation 'com.github.Traqueur-dev: CommandsAPI:VERSION'
54+ implementation 'com.github.Traqueur-dev. CommandsAPI:platform-spigot:4.0.0' // or platform-velocity
3355}
3456```
3557
36- #### For Maven include
37- ``` xml
58+ ### Maven
59+
60+ ``` xml
3861<repositories >
3962 <repository >
4063 <id >jitpack.io</id >
@@ -44,22 +67,26 @@ dependencies {
4467
4568<dependencies >
4669 <dependency >
47- <groupId >com.github.Traqueur-dev</groupId >
48- <artifactId >CommandsAPI </artifactId >
49- <version >VERSION </version >
70+ <groupId >com.github.Traqueur-dev.CommandsAPI </groupId >
71+ <artifactId >platform-spigot </artifactId > <!-- or platform-velocity -- >
72+ <version >4.0.0 </version >
5073 </dependency >
5174</dependencies >
5275```
53- Be sure to relocate commandsAPI in to prevent bugs with other plugins.
5476
55- ### Basic Usage
77+ > ⚠️ ** Relocate** the library when shading it into your plugin to avoid version conflicts with other plugins.
78+
79+ ---
80+
81+ ## 💡 Example (Spigot)
5682
57- To get started with CommandsAPI, create a new command by extending the ` Command<T extends JavaPlugin> ` class. Here’s a simple example:
83+ Be sure to extends all the classes from the platform you are using (Spigot, Velocity, etc.):
84+ ` fr.traqueur.commandsapi.spigot.CommandManager ` for Spigot, ` fr.traqueur.commandsapi.velocity.CommandManager ` for Velocity, etc.
5885
5986``` java
6087public class HelloWorldCommand extends Command<MyPlugin > {
6188
62- public HelloWorldCommand (JavaPlugin plugin ) {
89+ public HelloWorldCommand (MyPlugin plugin ) {
6390 super (plugin, " helloworld" );
6491 setDescription(" A simple hello world command" );
6592 setUsage(" /helloworld" );
@@ -72,41 +99,76 @@ public class HelloWorldCommand extends Command<MyPlugin> {
7299}
73100```
74101
75- Register the command in your plugin's ` onEnable ` method :
102+ Register the command:
76103
77104``` java
78- public class MyPlugin extends JavaPlugin {
105+ @Override
106+ public void onEnable() {
107+ CommandManager<MyPlugin > manager = new CommandManager<> (/* args depending of the platform*/ );
108+ manager. registerCommand(new HelloWorldCommand (this ));
109+ }
110+ ```
79111
80- @Override
81- public void onEnable () {
82- CommandManager<MyPlugin > commandManager = new CommandManager<> (this );
83- commandManager. registerCommands(new HelloWorldCommand (this ));
84- }
112+ ---
113+
114+ ## 🧠 Add New Platform Support
115+
116+ You can create your own adapter by implementing:
117+
118+ ``` java
119+ public interface CommandPlatform <T, S> {
120+ T getPlugin ();
121+ void injectManager (CommandManager<T , S > manager );
122+ Logger getLogger ();
123+ boolean hasPermission (S sender , String permission );
124+ void addCommand (Command<T , S > command , String label );
125+ void removeCommand (String label , boolean subcommand );
85126}
86127```
87128
88- ### Documentation
129+ This allows support for new platforms like Fabric, Minestom, or BungeeCord.
89130
90- For detailed documentation and usage examples, visit me [ Wiki ] ( https://github.com/Traqueur-dev/CommandsAPI/wiki ) .
131+ ---
91132
92- ## Contributing
133+ ## 🛠️ Local Development
93134
94- We welcome contributions to the CommandsAPI project! If you would like to contribute, please follow these steps :
135+ To publish locally for development :
95136
96- 1 . Fork the repository.
97- 2 . Create a new branch for your changes.
98- 3 . Commit your changes with clear and concise commit messages.
99- 4 . Push your changes to your fork.
100- 5 . Create a pull request with a description of your changes.
137+ ``` bash
138+ ./gradlew core:publishToMavenLocal platform-spigot:publishToMavenLocal platform-velocity:publishToMavenLocal
139+ ```
101140
102- ## License
141+ ---
103142
104- CommandsAPI is licensed under the [ MIT License ] ( LICENSE ) . See the LICENSE file for more details.
143+ ## 📚 Documentation
105144
106- ## Contact
145+ Visit the [ Wiki ] ( https://github.com/Traqueur-dev/CommandsAPI/wiki ) for:
107146
108- For any questions or support, please open an issue on the [ GitHub repository] ( https://github.com/Traqueur-dev/CommandsAPI/issues ) .
147+ * Tutorials
148+ * Examples
149+ * API Reference
150+ * Extending with custom types and logic
109151
110152---
111153
112- Happy coding and enjoy building your Minecraft plugins with CommandsAPI!
154+ ## 🤝 Contributing
155+
156+ We welcome contributions!
157+
158+ 1 . Fork this repository
159+ 2 . Create a new branch
160+ 3 . Implement your feature or fix
161+ 4 . Open a pull request with a clear description
162+
163+ ---
164+
165+ ## 📄 License
166+
167+ CommandsAPI is licensed under the [ MIT License] ( LICENSE ) .
168+
169+ ---
170+
171+ ## 💬 Support
172+
173+ Need help or want to report a bug?
174+ Open an issue on [ GitHub] ( https://github.com/Traqueur-dev/CommandsAPI/issues )
0 commit comments