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/en/create-commands/arguments/types/entities-arguments.md
+32-1
Original file line number
Diff line number
Diff line change
@@ -103,10 +103,41 @@ And there we have it! One thing to note is that entity selectors are still a val
103
103
104
104
## OfflinePlayer argument
105
105
106
-
The `OfflinePlayerArgument` class is identical to the `PlayerArgument` class, but instead of returning a `Player` object, it returns an `OfflinePlayer` object. Internally, this argument makes calls to Mojang servers (via Mojang's authlib), meaning it can be slightly slower than alternative methods (such as using a `StringArgument` and suggesting a list of existing offline players).
106
+
The `OfflinePlayerArgument` class is identical to the `PlayerArgument` class, but instead of returning a `Player` object, it returns an `OfflinePlayer` object. Internally, this argument makes calls to Mojang servers (via Mojang's authlib), meaning it can be slightly slower than alternative methods such as using a `AsyncOfflinePlayerArgument`, which runs the API call asynchronously, or using a `StringArgument` and suggesting a list of existing offline players.
107
107
108
108
The `OfflinePlayerArgument`_should_ be able to retrieve players that have never joined the server before.
109
109
110
+
## AsyncOfflinePlayer argument
111
+
112
+
The `AsyncOfflinePlayerArgument` class is identical to the `OfflinePlayerArgument` class, but instead of making the API call synchronously, it makes the API call asynchronously. This means that the command will not block the main thread while waiting for the API call to complete.
113
+
114
+
:::info
115
+
The `AsyncOfflinePlayerArgument` returns a `CompletableFuture<OfflinePlayer>` object, which can be used to retrieve the `OfflinePlayer` object when the API call is complete.
116
+
:::
117
+
118
+
::::tip Example - Checking if a player has joined before
119
+
120
+
Say we want to create a command that tells us if a player has joined the server before. We can use the `AsyncOfflinePlayerArgument` to fetch the `OfflinePlayer` object asynchronously. That way we simply wait for the request to complete, and once it does, we can check if the player has joined the server before. We want to create a command of the following form:
121
+
122
+
```mccmd
123
+
/playedbefore <player>
124
+
```
125
+
126
+
We now want to get the `CompletableFuture<OfflinePlayer>` object from the `AsyncOfflinePlayerArgument` and then use it to get the `OfflinePlayer` object. We can define it like this:
We now successfully ran a command that asynchronously checks if a player has joined the server before without blocking the main thread despite making an API call.
138
+
139
+
::::
140
+
110
141
## Entity type argument
111
142
112
143

Copy file name to clipboardExpand all lines: docs/en/create-commands/executors/native-sender.md
+20-1
Original file line number
Diff line number
Diff line change
@@ -67,4 +67,23 @@ This can now be used via the following command examples:
67
67
/execute in minecraft:overworld positioned 20 60 -20 run break
68
68
```
69
69
70
-
::::
70
+
::::
71
+
72
+
## Constructing a `NativeProxyCommandSender`
73
+
74
+
You can create a `NativeProxyCommandSender` object yourself using the static `from` method:
75
+
76
+
```java
77
+
NativeProxyCommandSender from(CommandSender caller, CommandSender callee, Location location, World world);
78
+
```
79
+
80
+
This `CommandSender` will work the same as any other `NativeProxyCommandSender` you would get while using `executesNative`. For example, you could use it to make a simple version of `/execute`, like so:
Copy file name to clipboardExpand all lines: docs/en/intro.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,7 @@ The CommandAPI does not follow the "standard" method of registering commands. In
27
27
28
28
-**Commands should not be declared in the `plugin.yml` file.**
29
29
- Commands are automatically registered under the namespace of the plugin that registered the command. For example, if you register a command `/hello`, you can also run it using `/<pluginname>:hello`. However, you can change the default namespace. More about this [on the command registration page](./create-commands/registration#registering-the-command).
30
-
- Commands are not "linked" to a certain plugin. In other words, you can’t look up which commands are registered by which plugin.
30
+
- Commands are not "linked" to a certain plugin. In other words, you can’t look up which commands are registered by which plugin. This is not the case for commands on Paper versions that have Paper's Brigadier API, or in other words, any Paper build starting in 1.20.6 with build 65.
Copy file name to clipboardExpand all lines: docs/en/upgrading-parts/9.7.0-to-10.0.0.md
+20
Original file line number
Diff line number
Diff line change
@@ -9,3 +9,23 @@ For 10.0.0, all previously deprecated methods have been removed. Please make sur
9
9
The default namespace has been updated from `minecraft` to the plugin's name. If you are not shading, the default namespace is going to be `commandapi`. If you are shading, the default namespace is going to be your plugin's name.
10
10
11
11
Along with this change, the `CommandAPIBukkitConfig#usePluginNamespace()` has been deprecated since it is now default behaviour.
12
+
13
+
-----
14
+
15
+
### `NativeProxyCommandSender` changes
16
+
17
+
`NativeProxyCommandSender` used to be a class, but this version changed it to an interface. Any code compiled against an earlier version that references any method of `NativeProxyCommandSender` may throw the following `IncompatibleClassChangeError` when run using the new version of the API:
18
+
19
+
```
20
+
java.lang.IncompatibleClassChangeError: Found interface dev.jorel.commandapi.wrappers.NativeProxyCommandSender, but class was expected
21
+
```
22
+
23
+
If this happens, the original code simply needs to be recompiled using the new API version.
24
+
25
+
Additionally, the constructor of `NativeProxyCommandSender` is no longer available. Instead, the static `from` method should be used:
As explained on the page about command and argument [requirements](../create-commands/requirements.md#updating-requirements), you should run `CommandAPI.updateRequirements(player)` whenever conditions that affect whether a player can access a command change. However, Velocity is not able to resend commands to a client by itself; it only knows how to add commands to a packet the backend server sent. So, in order for `updateRequirements` to work, the CommandAPI needs to be able to tell the backend server to resend commands.
112
+
113
+
The CommandAPI Velocity plugin handles this by sending a plugin message to the backend server. In order for the backend server to process this message, you must add a plugin that understands CommandAPI plugin messages. You can easily do this by installing the CommandAPI Bukkit plugin or any plugin that shades CommandAPI version 10.0.0 or later to each backend server. However, the CommandAPI Bukkit plugin includes a lot of extra stuff to make registering commands work, which isn't necessary if you only need `updateRequirements` to work on Velocity. In this case, you can install the special CommandAPI Bukkit Networking plugin, which simply contains the code necessary to respond to plugin messages.
114
+
115
+
Whether you want to install the CommandAPI Bukkit plugin or the CommandAPI Bukkit Networking plugin, you can find the latest releases [here](https://github.com/CommandAPI/CommandAPI/releases/latest).
116
+
117
+
So far, the CommandAPI only uses the plugin messaging system to implement `updateRequirements` on Velocity. If you're not using `updateRequirements` on Velocity, you don't need to install a CommandAPI plugin on your backend servers. It is possible that future features will take advantage of the plugin messaging system as CommandAPI Velocity is further developed. If this ever happens, you should see a clear error message prompting you to update to a compatible version.
0 commit comments