You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/paper/dev/api/command-api/arguments/adventure-arguments.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -148,7 +148,7 @@ on that resulting completable future. Inside of that, you can send the signed me
148
148
:::warning
149
149
150
150
The use of thread unsafe Bukkit API inside the `.thenAccept` method is not supported, as this is an asynchronous method, which does not run on the main thread.
151
-
If you need to use Bukkit API, you can schedule a task to be run on the next available tick. You can read up on that **here** (WIP).
151
+
If you need to use Bukkit API, you can schedule a task to be run on the next available tick. You can read up on that [here](../../scheduler.mdx).
Copy file name to clipboardExpand all lines: docs/paper/dev/api/command-api/arguments/bukkit-arguments.mdx
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,7 +39,7 @@ public static LiteralCommandNode<CommandSourceStack> blockStateArgument() {
39
39
40
40
## ItemStack Argument
41
41
The item stack argument is a way to retrieve an `ItemStack` following the same argument format as the vanilla `/give <player> <item> [<amount>]` command as its second argument.
42
-
The user may also define components to further customize the `ItemStack`. If you only require a material, you should instead check out the **Registry Arguments** (WIP).
42
+
The user may also define components to further customize the `ItemStack`. If you only require a material, you should instead check out the [registry arguments](./registry-arguments.mdx).
43
43
44
44
### Example usage
45
45
```java
@@ -139,7 +139,7 @@ public static LiteralCommandNode<CommandSourceStack> timeArgument() {
139
139
## UUID Argument
140
140
The uuid argument allows the user to input a valid uuid. You can retrieve that value as a `UUID` object, which is used in various places, like `Bukkit.getOfflinePlayer(UUID)`.
141
141
This argument is not very user-friendly, which is why it is suggested to only use this as a moderation or debug argument. For user input regarding offline player
142
-
retrieval, the **player profiles argument** (WIP) is preferred, as it allows by-name lookup.
142
+
retrieval, the [player profiles argument](./entity-player-arguments#player-profiles-argument) is preferred, as it allows by-name lookup.
A `BasicCommand` is a bukkit-like way of defining commands. Instead of building up a command tree, we allow all user input and retrieve the arguments as a simple array of Strings.
120
-
This type of commands is particularly useful for very simple, text based commands, like a `/broadcast` command. You can read up on more details **here** (WIP).
120
+
This type of commands is particularly useful for very simple, text based commands, like a `/broadcast` command. You can read up on more details about basic commands
121
+
[here](../misc/basic-command.mdx).
121
122
122
123
Assuming you already have your `BasicCommand` object, we can register it like this:
Copy file name to clipboardExpand all lines: docs/paper/dev/api/command-api/misc/basic-command.mdx
+10Lines changed: 10 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -61,6 +61,7 @@ With the permission method you can, similar to the `canUse` method, set the perm
61
61
62
62
## Example: Broadcast command
63
63
As an example, we can create a simple broadcast command. We start by declaring creating a class which implements BasicCommand and overrides `execute` and `permission`:
64
+
64
65
```java
65
66
packageyour.package.name;
66
67
@@ -86,6 +87,7 @@ Our permission is set to `example.broadcast.use`. In order to give yourself that
86
87
operator permissions. You can also set this permission to be `true` by default. For this, please check out the [plugin.yml documentation](../../../getting-started/plugin-yml.mdx).
87
88
88
89
Now, in our `execute` method, we can retrieve the name of the executor of that command. If we do not find one, we can just get the name of the command sender, like this:
90
+
89
91
```java
90
92
finalComponent name;
91
93
if (commandSourceStack.getExecutor() !=null) {
@@ -99,6 +101,7 @@ else {
99
101
This makes sure that we cover all cases and even allow the command to work correctly with `/execute as`.
100
102
101
103
Next, we retrieve all arguments and join them to a String or tell the sender that at least one argument is required in order to send a broadcast
104
+
102
105
if they defined no arguments (meaning that `args` has a length of 0):
After this, we can add a `filter` clause to our stream, where we filter all names by whether they start with our current input, which is `args[args.length - 1]`:
214
+
206
215
```java
207
216
returnBukkit.getOnlinePlayers().stream()
208
217
.map(Player::getName)
@@ -218,6 +227,7 @@ But when there is no player who starts with an input, it just suggests nothing:
218
227
219
228
### Final code
220
229
Here is the final code for our whole `BroadcastCommand` class, including the suggestions:
0 commit comments