|
| 1 | +# CommandAPI |
| 2 | +Simple Reflection Command API that just does what you want it to do without any problems. |
| 3 | + |
| 4 | +* Currently not tested, please do not use unless this read me is changed. |
| 5 | + |
| 6 | +### Importing |
| 7 | + |
| 8 | +* Maven |
| 9 | + |
| 10 | +```xml |
| 11 | + <repository> |
| 12 | + <id>jitpack.io</id> |
| 13 | + <url>https://jitpack.io</url> |
| 14 | + </repository |
| 15 | +``` |
| 16 | + |
| 17 | +```xml |
| 18 | + <dependency> |
| 19 | + <groupId>com.github.therealdamt</groupId> |
| 20 | + <artifactId>commandapi</artifactId> |
| 21 | + <version>1.0</version> |
| 22 | + </dependency> |
| 23 | +``` |
| 24 | + |
| 25 | +* Gradle |
| 26 | + |
| 27 | +```gradle |
| 28 | + repositories { |
| 29 | + ... |
| 30 | + maven { url 'https://jitpack.io' } |
| 31 | + } |
| 32 | +``` |
| 33 | + |
| 34 | +```gradle |
| 35 | + dependencies { |
| 36 | + implementation 'com.github.therealdamt:commandapi:Tag' |
| 37 | + } |
| 38 | +``` |
| 39 | + |
| 40 | +### How to use |
| 41 | + |
| 42 | +* Example main class |
| 43 | + |
| 44 | +```java |
| 45 | +public class Main extends JavaPlugin { |
| 46 | + |
| 47 | + @Getter |
| 48 | + private static Main instance; |
| 49 | + |
| 50 | + private CommandHandler commandHandler; |
| 51 | + |
| 52 | + @Override |
| 53 | + public void onLoad() { |
| 54 | + instance = this; |
| 55 | + } |
| 56 | + |
| 57 | + @Override |
| 58 | + public void onEnable() { |
| 59 | + this.commandHandler = new CommandHandler(this); |
| 60 | + commandHandler.register(new FlyCommand()); |
| 61 | + } |
| 62 | + |
| 63 | +} |
| 64 | +``` |
| 65 | + |
| 66 | +* Example command class |
| 67 | + |
| 68 | +``` |
| 69 | +public class FlyCommand { |
| 70 | +
|
| 71 | + /** |
| 72 | + * So this is a simple command example |
| 73 | + * There are 2 rules to every command: |
| 74 | + * <p> |
| 75 | + * 1- Must have a sender could be a player or a command sender |
| 76 | + * 2- Must have an array of strings |
| 77 | + * |
| 78 | + * @param player sender |
| 79 | + * @param args arguments to execute with |
| 80 | + */ |
| 81 | +
|
| 82 | + @Command(value = "fly", description = "Fly Command", usage = "fly") |
| 83 | + @Permission(permission = "command.fly", message = "You may not use this command!") |
| 84 | + public void flyCommand(@Sender Player player, String[] args) { |
| 85 | + player.setAllowFlight(!player.getAllowFlight()); |
| 86 | +
|
| 87 | + String isFlying = player.getAllowFlight() ? "&aenabled" : "&cdisabled"; |
| 88 | + player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&aYour flying is now " + isFlying)); |
| 89 | + } |
| 90 | +
|
| 91 | +} |
| 92 | +``` |
| 93 | + |
| 94 | +### Credits |
| 95 | + |
| 96 | +You have full rights to use this command api within your projects, but if possible to include credits that'd be amazing! |
| 97 | + |
| 98 | +### Contact |
| 99 | + |
| 100 | +* [Telegram](https://t.me/therealdamt) |
| 101 | +* [Website](https://damt.xyz) |
| 102 | +* Discord | damt#0886 |
0 commit comments