Skip to content

Commit

Permalink
Added argument guide in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Zffu committed Jul 25, 2024
1 parent bf1b5c5 commit ee5d354
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,27 @@ For example, you could make your command require the invoker to be a player and
builder.type(InvokerType.PLAYER).permission("test.permission");
```

#### Adding Arguments
In order to add arguments to your command you can use the `Arguments` class to generate the arguments.

For example lets make a string argument.
```java
builder.argument(Arguments.string());
```

To make the argument optional simply do that instead:
```java
builder.argument(Arguments.string().optional(true));
```

**INFO:** Arguments are required by default.

#### Make the command do something
In order to make the command do something, you can use the `execute` builder function.

In this example, we make the command send "hello" to the player who executed the command (for Spigot):
In this example, we make the command send "hello (argument 1)" to the player who executed the command (for Spigot):
```java
builder.execute((ctx) -> (((PlayerInvoker)ctx.getInvoker()).getPlayer()).sendMessage("Hello"))
builder.execute((ctx) -> (((PlayerInvoker)ctx.getInvoker()).getPlayer()).sendMessage("Hello " + ctx.get(0, String.class)))
```

#### Building the command
Expand Down

0 comments on commit ee5d354

Please sign in to comment.