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.mdx
+13-10Lines changed: 13 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ import SignedMessageMp4 from "./assets/vanilla-arguments/signedmessage.mp4";
11
11
12
12
# Adventure Library Arguments
13
13
These arguments return a class from the `net.kyori` package. They are technically not native to Minecraft or Bukkit, but as Paper includes the Adventure library, they are
14
-
usually widely used in the Paper ecosystem.
14
+
widely used in the Paper ecosystem.
15
15
16
16
## Component argument
17
17
:::note
@@ -46,8 +46,8 @@ public static LiteralCommandNode<CommandSourceStack> componentArgument() {
46
46
47
47
48
48
## Key argument
49
-
The key argument allows a user to put in any artificial (namespaced) key, ensuring its validity. This returns a `net.kyori.adventure.key.Key` from the Adventure library,
50
-
which can be used at various other places in the Bukkit/Paper API.
49
+
The key argument allows a user to put in any artificial (namespaced) key, ensuring its validity. This returns a [`Key`](https://jd.advntr.dev/key/latest/net/kyori/adventure/key/Key.html),
50
+
which can be used at various other places in the Paper API.
51
51
52
52
### Example usage
53
53
```java
@@ -73,7 +73,8 @@ public static LiteralCommandNode<CommandSourceStack> keyArgument() {
73
73
74
74
## Named color argument
75
75
This argument provides the user with the ability to select between the 16 built-in "named" text colors. This argument returns a
76
-
`net.kyori.adventure.text.format.NamedTextColor` which you can use for styling components.
which you can use for applying a color to components.
77
78
78
79
### Example usage
79
80
```java
@@ -102,13 +103,12 @@ public static LiteralCommandNode<CommandSourceStack> namedColorArgument() {
102
103
:::note
103
104
104
105
Similar to the component argument, this argument is not really appropriate for general user input, as it also follows the JSON format for displaying components. Most users
105
-
106
106
do not know how to use that format and thus its general usage is not advised.
107
107
108
108
:::
109
109
110
-
The style argument returns its value in the form of an `net.kyori.adventure.text.format.Style` object. This can be applied to any component using `Component#style(Style)`.
111
-
Whilst the JSON input allows for the `text` field, its content is completely ignored.
110
+
The style argument returns its value in the form of a [`Style`](https://javadoc.io/doc/net.kyori/adventure-api/latest/net/kyori/adventure/text/format/Style.html) object.
111
+
This can be applied to any component using `Component#style(Style)`. Whilst the JSON input allows for the `text` field, its content is completely ignored.
112
112
113
113
### Example usage
114
114
```java
@@ -142,19 +142,22 @@ A signed message argument returns a `SignedMessageResolver`. In order to call it
142
142
* The argument name
143
143
* The `CommandContext<CommandSourceStack>` object
144
144
145
-
The resolved value is a `CompletableFuture<SignedMessage>`, whose `SignedMessage` value you can handle using a `thenAccept(Consumer<T>)`. Inside of the consumer, you can send the signed message to players or work with it in other ways.
145
+
The resolved value is a `CompletableFuture<SignedMessage>`, whose [`SignedMessage`](https://javadoc.io/doc/net.kyori/adventure-api/latest/net/kyori/adventure/chat/SignedMessage.html)
146
+
value you can handle using `thenAccept(Consumer<T>)`. Inside of the consumer, you can send the signed message to players or work with it in other ways.
146
147
147
148
:::warning
148
149
149
150
By default, the consumer passed into `thenAccept` is not executed on the main thread, making it unsafe to use most of Paper API within it.
150
-
If you need to use the API, you can schedule a task to be run on the next available tick. For this you can use the <Javadocname="org.bukkit.scheduler.BukkitScheduler#getMainThreadExecutor(org.bukkit.plugin.Plugin)">main thread executor</Javadoc>.
151
+
If you need to use the API, you can schedule a task to be run on the next available tick. For this you can use the
You can read up on that [here](../../scheduler.mdx).
152
154
153
155
:::
154
156
155
157
:::note
156
158
157
-
A non-player sender is not capable of sending a signed message, which means that the resolved `CompletableFuture` will never be completed. You should make sure that only players can use your argument with `.requires(ctx -> ctx.getSender() instanceof Player)` on your `SignedArgument`. You may
159
+
A non-player sender is not capable of sending a signed message, which means that the resolved `CompletableFuture` will never be completed.
160
+
You should make sure that only players can use your argument with `.requires(ctx -> ctx.getSender() instanceof Player)` on your `SignedArgument`. You may
158
161
add a fallback greedy string argument for non-player senders if you want the argument to execute regardless of signing.
Copy file name to clipboardExpand all lines: docs/paper/dev/api/command-api/basics/command-tree.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
@@ -59,8 +59,8 @@ stateDiagram-v2
59
59
```
60
60
</p>
61
61
62
-
It is important to remember that this tree-like structure is not only important for Brigadier. It is a fairly often used concept. Paper's included **Adventure API** also operates using
63
-
a tree. Why is this important for using Brigadier though? Well, it allows for explicit command declaration. Being at a node, you know exactly where you are. That means you do not have
62
+
It is important to remember that this tree-like structure is not only important for Brigadier. It is a fairly often used concept. Paper's included [Adventure API](../../component-api/intro.mdx)
63
+
also operates using a tree. Why is this important for using Brigadier though? Well, it allows for explicit command declaration. Being at a node, you know exactly where you are. That means you do not have
64
64
to, like in standard Bukkit way, first check whether the amount of arguments is 2 and the first argument is `tphere`. Because you are at that exact `tphere` node, you can just start writing
65
65
your logic. If you want to learn more about the execute logic of Brigadier commands, it is suggested that you check out [command executors](./executors).
Copy file name to clipboardExpand all lines: docs/paper/dev/api/command-api/misc/basic-command.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
@@ -83,7 +83,7 @@ public class BroadcastCommand implements BasicCommand {
83
83
}
84
84
```
85
85
86
-
Our permission is set to `example.broadcast.use`. In order to give yourself that permission, it is suggested that you use a plugin like **LuckPerms** or just give yourself
86
+
Our permission is set to `example.broadcast.use`. In order to give yourself that permission, it is suggested that you use a plugin like [LuckPerms](https://luckperms.net) or just give yourself
87
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).
88
88
89
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:
0 commit comments