|
| 1 | +# ForestCommandAPI |
| 2 | + |
| 3 | + |
| 4 | +[](https://jitpack.io/#ForestTechMC/ForestCommandAPI) |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | +[](https://discord.gg/2PpdrfxhD4) |
| 9 | +[](https://github.com/ForestTechMC/ForestCommandAPI/blob/master/LICENSE.txt) |
| 10 | + |
| 11 | +Simple, but powerful annotation-based multiplatform command API inspired by many of the available APIs. |
| 12 | + |
| 13 | +⚠️ **Project is at the beginning of development! We recommend not to use it right now!** ⚠️ |
| 14 | + |
| 15 | +## Table of contents |
| 16 | + |
| 17 | +* [Getting started](#getting-started) |
| 18 | +* [Usage](#usage) |
| 19 | +* [License](#license) |
| 20 | + |
| 21 | +## Getting started |
| 22 | + |
| 23 | +This API works as library - it does not require to install any file to the server. |
| 24 | + |
| 25 | +### Add ForestCommandAPI to your project |
| 26 | + |
| 27 | +[](https://jitpack.io/#ForestTechMC/ForestCommandAPI) |
| 28 | + |
| 29 | +First, you need to setup the dependency on the ForestCommandAPI. |
| 30 | +Replace **VERSION** with the version of the release. |
| 31 | +Replace **PLATFORM** with the name of the supported platforms (currently "paper", in the future "velocity", "spigot" and "bungeecord" will follow). |
| 32 | + |
| 33 | +<details> |
| 34 | + <summary>Maven</summary> |
| 35 | + |
| 36 | +```xml |
| 37 | +<repositories> |
| 38 | + <repository> |
| 39 | + <id>jitpack.io</id> |
| 40 | + <url>https://jitpack.io</url> |
| 41 | + </repository> |
| 42 | +</repositories> |
| 43 | + |
| 44 | +<dependencies> |
| 45 | + <dependency> |
| 46 | + <groupId>com.github.ForestTechMC.ForestCommandAPI</groupId> |
| 47 | + <artifactId>PLATFORM</artifactId> |
| 48 | + <version>VERSION</version> |
| 49 | + </dependency> |
| 50 | +</dependencies> |
| 51 | +``` |
| 52 | +</details> |
| 53 | + |
| 54 | +<details> |
| 55 | + <summary>Gradle</summary> |
| 56 | + |
| 57 | +```gradle |
| 58 | +allprojects { |
| 59 | + repositories { |
| 60 | + ... |
| 61 | + maven { url 'https://jitpack.io' } |
| 62 | + } |
| 63 | +} |
| 64 | +
|
| 65 | +dependencies { |
| 66 | + implementation 'com.github.ForestTechMC.ForestCommandAPI:PLATFORM:VERSION' |
| 67 | +} |
| 68 | +``` |
| 69 | +</details> |
| 70 | + |
| 71 | +## Usage |
| 72 | + |
| 73 | +MyCommand.java |
| 74 | +```java |
| 75 | +// Use onEnable or similar method based on the platform |
| 76 | +@Command(name = "mycmd") |
| 77 | +public class MyCommand implements CommandProcessor { |
| 78 | + |
| 79 | + @SubCommand |
| 80 | + public void defaultNoArgs(CommandSender commandSender) { |
| 81 | + commandSender.sendMessage("Command with no args!"); |
| 82 | + } |
| 83 | + |
| 84 | + @SubCommand(names = "first") |
| 85 | + public void prefixNoArgs(CommandSender commandSender) { |
| 86 | + commandSender.sendMessage("Sub-command with no args!"); |
| 87 | + } |
| 88 | + |
| 89 | + @SubCommand(names = "second") |
| 90 | + public void prefixWithArgs(CommandSender commandSender, @Arg(name="arg1") String arg1, @Arg(name="int-arg", required=false) Integer arg2) { |
| 91 | + commandSender.sendMessage("Sub-command with args: " + arg1 + " " + arg2); |
| 92 | + } |
| 93 | + |
| 94 | +} |
| 95 | +``` |
| 96 | + |
| 97 | +Main.java |
| 98 | +```java |
| 99 | +// Use onEnable or similar method based on the platform |
| 100 | +@Override |
| 101 | +public void onEnable() { |
| 102 | + CommandAPI commandAPI = new CommandAPI(this); // plugin main as the argument |
| 103 | + |
| 104 | +} |
| 105 | +``` |
| 106 | + |
| 107 | +## License |
| 108 | +ForestCommandAPI is licensed under the permissive MIT license. Please see [`LICENSE.txt`](https://github.com/ForestTechMC/ForestCommandAPI/blob/master/LICENSE.txt) for more information. |
0 commit comments