Skip to content

Commit aae7f5c

Browse files
authored
Update README.md
1 parent 0693e78 commit aae7f5c

File tree

1 file changed

+27
-25
lines changed

1 file changed

+27
-25
lines changed

README.md

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,21 @@ Simple Reflection Command API that just does what you want it to do without any
4040
* Example main class
4141

4242
```java
43+
@Getter
4344
public class Main extends JavaPlugin {
4445

4546
@Getter
4647
private static Main instance;
4748

48-
private CommandHandler commandHandler;
49-
5049
@Override
5150
public void onLoad() {
5251
instance = this;
5352
}
5453

5554
@Override
5655
public void onEnable() {
57-
this.commandHandler = new CommandHandler(this);
58-
commandHandler.register(new FlyCommand());
59-
commandHandler.registerCommands();
56+
new CommandHandler(this).bind(ItemStack.class, new ItemStackProvider())
57+
.register(new FlyCommand(), new ItemStackCommand()).registerCommands();
6058
}
6159

6260
}
@@ -65,26 +63,30 @@ public class Main extends JavaPlugin {
6563
* Example command class
6664

6765
```java
68-
public class FlyCommand {
69-
70-
/**
71-
* So this is a simple command example
72-
* There are 2 rules to every command:
73-
* <p>
74-
* 1- Must have a sender could be a player or a command sender
75-
* 2- Must have an array of strings
76-
*
77-
* @param player sender
78-
* @param args arguments to execute with
79-
*/
80-
81-
@Command(value = "fly", description = "Fly Command", usage = "fly")
82-
@Permission(permission = "command.fly", message = "You may not use this command!")
83-
public void flyCommand(@Sender Player player, String[] args) {
84-
player.setAllowFlight(!player.getAllowFlight());
85-
86-
String isFlying = player.getAllowFlight() ? "&aenabled" : "&cdisabled";
87-
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&aYour flying is now " + isFlying));
66+
public class ItemStackCommand {
67+
68+
@Command(value = "kekw", async = true, usage = "/kekw itemStack", description = "Just makes an itemstack lol")
69+
@Permission(permission = "kekw.kekew", message = "no perm noob")
70+
public void itemStackCommand(@Sender Player player, @Name("itemStack") ItemStack itemStack) {
71+
player.getInventory().addItem(itemStack);
72+
player.sendMessage(ChatColor.GREEN + "Gave ya your itemstack!");
73+
}
74+
75+
}
76+
```
77+
78+
#Example provider
79+
80+
```java
81+
public class ItemStackProvider implements CommandProvider<ItemStack> {
82+
83+
@Override
84+
public ItemStack provide(String s) throws CommandProviderNullException {
85+
86+
if (!s.equalsIgnoreCase("itemStack"))
87+
throw new CommandProviderNullException(ChatColor.RED + "You need to type 'itemStack' to get this provider!");
88+
89+
return new ItemStack(Material.DIRT);
8890
}
8991

9092
}

0 commit comments

Comments
 (0)