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/chat/adventure-chat-arguments.md
+11-9Lines changed: 11 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,21 +8,23 @@ authors:
8
8
9
9
# Adventure chat arguments
10
10
11
-
:::info
11
+
From Paper 1.16.5 build #473 onwards, Paper now includes [Kyori's Adventure API](https://github.com/KyoriPowered/adventure-platform). This library is a replacement of the BungeeCord chat API and has all the same functionality as the BungeeCord chat API (and more!). The documentation for this API can be found [here](https://docs.adventure.kyori.net/index.html).
12
12
13
-
The two following classes, `AdventureChatComponentArgument` and `AdventureChatArgument` depend on a Paper-based server which has the Adventure library. If you use this class on a server without the Adventure library, it will throw a `PaperAdventureNotFoundException`
13
+
Since this functions very similar to the Spigot chat arguments, this page won't reiterate everything about how it works, we'll just outline some examples of how to use these arguments instead.
14
+
Additionally, the names used here may be confusing as they are the same names as on the [Spigot chat arguments](spigot-chat-arguments.md) page but have different return types. This is because the classes on this page are only accessible using `commandapi-paper-core` or `commandapi-paper-shade`
15
+
while the arguments on the Spigot chat arguments page are only available when using `commandapi-spigot-core` or `commandapi-spigot-shade`.
14
16
15
-
:::
17
+
:::info
16
18
17
-
From Paper 1.16.5 build #473 onwards, Paper now includes [Kyori's Adventure API](https://github.com/KyoriPowered/adventure-platform). This library is a replacement of the BungeeCord chat API and has all the same functionality as the BungeeCord chat API (and more!). The documentation for this API can be found [here](https://docs.adventure.kyori.net/index.html).
19
+
The three following classes, `ChatColorArgument`, `ChatComponentArgument` and `ChatArgument` depend on a Paper based server which has the Adventure library. If you use any of these classes on a server without the Adventure library, they will throw a `PaperAdventureNotFoundException`.
18
20
19
-
Since this functions very similar to the Spigot chat arguments, this page won't reiterate everything about how it works, we'll just outline some examples of how to use these arguments instead.
21
+
:::
20
22
21
23
## Adventure chat color argument
22
24
23
25

24
26
25
-
The `AdventureChatColorArgument` class is used to represent a given chat color (e.g., red or green). This argument returns the `NamedTextColor` object. If `reset` is passed to this argument, this will return `NamedTextColor.WHITE`.
27
+
The `ChatColorArgument` class is used to represent a given chat color (e.g., red or green). This argument returns the `NamedTextColor` object. If `reset` is passed to this argument, this will return `NamedTextColor.WHITE`.
26
28
27
29
::::tip Example – Username color changing plugin
28
30
@@ -47,7 +49,7 @@ We then use the `ChatColorArgument` to change the player's name color:
47
49
48
50
## Adventure chat component argument
49
51
50
-
The `AdventureChatComponentArgument` class accepts raw chat-based JSON as valid input, as declared [here](https://minecraft.wiki/w/Raw_JSON_text_format). This is converted into Adventure's `Component` class.
52
+
The `ChatComponentArgument` class accepts raw chat-based JSON as valid input, as declared [here](https://minecraft.wiki/w/Raw_JSON_text_format). This is converted into Adventure's `Component` class.
51
53
52
54
::::tip Example – Opening a book with raw JSON content
53
55
@@ -72,11 +74,11 @@ We can construct a book using the Adventure API's `Book.book(Component, Componen
72
74
73
75
## Adventure chat argument
74
76
75
-
The `AdventureChatArgument` class is the equivalent Adventure API class for the `ChatArgument`- it represents infinitely long strings similar to the `GreedyStringArgument` and allows entity selectors such as `@e`, `@p` and so on. The `AdventureChatArgument` returns a `Component`, similar to the `AdventureChatComponentArgument`.
77
+
The `ChatArgument` represents infinitely long strings similar to the `GreedyStringArgument` and allows entity selectors such as `@e`, `@p` and so on. The `ChatArgument` returns a `Component`, similar to the `ChatComponentArgument`.
76
78
77
79
::::tip Example – Sending personalized messages to players
78
80
79
-
We'll take the same example from the `ChatArgument` class, but using the `AdventureChatArgument` instead - We want to create a personalized message broadcasted to all users using a chat component that allows entity selectors. For this command, we want the following syntax:
81
+
We want to create a personalized message broadcasted to all users using a chat component that allows entity selectors. For this command, we want the following syntax:
CommandAPIConfigsilentLogs(booleanvalue); // Disables ALL logging (except errors)
40
-
CommandAPIConfiguseLatestNMSVersion(booleanvalue); // Whether the latest NMS implementation should be used or not
41
-
CommandAPIConfigbeLenientForMinorVersions(booleanvalue); // Whether the CommandAPI should be more lenient with minor Minecraft versions
42
-
CommandAPIConfigmissingExecutorImplementationMessage(Stringvalue); // Set message to display when executor implementation is missing
43
40
CommandAPIConfigdispatcherFile(Filefile); // If not null, the CommandAPI will create a JSON file with Brigadier's command tree
44
41
CommandAPIConfigsetNamespace(Stringnamespace); // The namespace to use when the CommandAPI registers a command
45
-
46
-
<T>CommandAPIConfiginitializeNBTAPI(Class<T>nbtContainerClass, Function<Object, T>nbtContainerConstructor); // Initializes hooks with an NBT API. See NBT arguments documentation page for more info
47
42
}
48
43
```
49
44
50
45
The `CommandAPIConfig` class follows a typical builder pattern (without you having to run `.build()` at the end), which lets you easily construct configuration instances.
51
46
52
-
However, the `CommandAPIConfig` class is abstract and can’t be used to configure the CommandAPI directly. Instead, you must use a subclass of `CommandAPIConfig` that corresponds to the platform you’re developing for. For example, when developing for Bukkit, you should use the `CommandAPIBukkitConfig` class.
47
+
However, the `CommandAPIConfig` class is abstract and can’t be used to configure the CommandAPI directly. Instead, you must use a subclass of `CommandAPIConfig` that corresponds to the platform you’re developing for. For example, when developing for a Bukkit-based server, you should use the `CommandAPIPaperConfig` or the `CommandAPISpigotConfig` class.
53
48
54
49
<!-- TODO: Add tabs and explanations for other platforms -->
CommandAPIBukkitConfiguseLatestNMSVersion(booleanvalue); // Whether the latest NMS implementation should be used or not
56
+
CommandAPIBukkitConfigbeLenientForMinorVersions(booleanvalue); // Whether the CommandAPI should be more lenient with minor Minecraft versions
57
+
CommandAPIBukkitConfigmissingExecutorImplementationMessage(Stringvalue); // Set message to display when executor implementation is missing
58
+
<T>CommandAPIConfiginitializeNBTAPI(Class<T>nbtContainerClass, Function<Object, T>nbtContainerConstructor); // Initializes hooks with an NBT API. See NBT arguments documentation page for more info
CommandAPIBukkitConfigshouldHookPaperReload(booleanhooked); // Whether the CommandAPI should hook into the Paper-exclusive ServerResourcesReloadedEvent
61
-
CommandAPIBukkitConfigskipReloadDatapacks(booleanskip); // Whether the CommandAPI should reload datapacks on server load
72
+
CommandAPISpigotConfigskipReloadDatapacks(booleanskip); // Whether the CommandAPI should reload datapacks on server load
62
73
}
63
74
```
75
+
:::
64
76
65
-
In order to create a `CommandAPIBukkitConfig`object, you must give it a reference to your `JavaPlugin` instance. The CommandAPI always uses this to register events, so it is required when loading the CommandAPI on Bukkit. There are also Bukkit-specific features, such as the `hook-paper-reload` configuration option, which may be configured using a `CommandAPIBukkitConfig` instance.
77
+
In order to create a `CommandAPIPaperConfig` or a `CommandAPISpigotConfig`object, you must give it a reference to your `JavaPlugin` instance. The CommandAPI always uses this to register events, so it is required when loading the CommandAPI on Bukkit. There are also platform-specific features, such as the `hook-paper-reload` configuration option on Paper, which may be configured using a `CommandAPIPaperConfig` instance.
66
78
67
79
For example, to load the CommandAPI on Bukkit with all logging disabled, you can use the following:
68
80
@@ -112,23 +124,25 @@ Add the CommandAPI shade dependency:
Copy file name to clipboardExpand all lines: docs/en/kotlin-dsl/intro.md
+35-4Lines changed: 35 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,21 +15,34 @@ This DSL provides many methods to easily add arguments to your command structure
15
15
16
16
## Installing the DSL
17
17
18
-
To install the DSL, you need to add the `commandapi-bukkit-kotlin`dependency into your `pom.xml` or your `build.gradle`, making sure to specify the server flavor you are developing for:
18
+
To install the DSL, you need to add the Kotlin DSL dependency into your build script, making sure to specify the server flavor you are developing for:
19
19
20
20
### Adding the dependency
21
21
22
22
<divclass="maven">
23
23
24
+
:::tabs
25
+
===Paper
24
26
```xml
25
27
<dependencies>
26
28
<dependency>
27
29
<groupId>dev.jorel</groupId>
28
-
<artifactId>commandapi-bukkit-kotlin</artifactId>
30
+
<artifactId>commandapi-kotlin-paper</artifactId>
29
31
<version>11.0.0-SNAPSHOT</version>
30
32
</dependency>
31
33
</dependencies>
32
34
```
35
+
===Spigot
36
+
```xml
37
+
<dependencies>
38
+
<dependency>
39
+
<groupId>dev.jorel</groupId>
40
+
<artifactId>commandapi-kotlin-spigot</artifactId>
41
+
<version>11.0.0</version>
42
+
</dependency>
43
+
</dependencies>
44
+
```
45
+
:::
33
46
34
47
Next, you need to add Kotlin to your project. For this, you first need to add the dependency:
35
48
@@ -104,20 +117,38 @@ Next, you need to add the dependency:
For 11.0.0, the `commandapi-bukkit-xxx` modules have mostly been removed in favour of new platform specific modules that have been made for Paper or Spigot respectively:
6
+
7
+
-`commandapi-paper-xxx`
8
+
-`commandapi-spigot-xxx`
9
+
10
+
In order to update please replace your `commandapi-bukkit-xxx` dependency with either `commandapi-paper-xxx` or `commandapi-spigot-xxx`.
11
+
12
+
:::danger **Developer's Note:**
13
+
14
+
The fact that Paper is a fork of Spigot does not mean that the Spigot modules work on Paper. Paper has, especially in newer versions, made changes to internal systems the CommandAPI
15
+
uses. There are no guarantees that the Spigot modules will work on Paper in any kind or form.
16
+
17
+
Similarly, if you try to use the Paper modules on Spigot you will face registration issues and potential `NoClassDefFoundError`s, depending on the server version you use.
18
+
There again is no guarantee for any kind of compatibility.
19
+
20
+
:::
21
+
22
+
Additionally, the Kotlin module artifact names have changed. Instead of following the pattern `commandapi-bukkit-xxx`, they have now been updated as follows:
23
+
24
+
-`commandapi-core-kotlin`: was changed to `commandapi-kotlin-core`
25
+
-`commandapi-bukkit-kotlin`: was changed to `commandapi-kotlin-bukkit`
26
+
27
+
#### Code changes
28
+
29
+
The `CommandAPIBukkitConfig` class has been converted into an abstract class and is no longer used to construct a config instance. Instead, use the new `CommandAPIPaperConfig` or
30
+
`CommandAPISpigot` classes, depending on the module you use.
31
+
32
+
Further changes have been made to arguments that work with components. The classes `AdventureChatArgument`, `AdventureChatComponentArgument` and `AdventureChatColorArgument` have been
33
+
removed. Instead, the `ChatArgument`, `ChatComponentArgument` and `ChatColorArgument` have been implemented platform specific and return different types on Paper and Spigot.
34
+
On Paper, Adventure components are used while Spigot uses BungeeCord components.
35
+
36
+
More argument changes have been made:
37
+
38
+
- The `FloatRangeArgument` has been renamed to `DoubleRangeArgument` and now returns a `DoubleRange` object
39
+
- The `PlayerArgument` and `OfflinePlayerArgument` have been replaced by the `PlayerProfileArgument` which returns a `List<PlayerProfile>`. The `PlayerProfile` class changes depending on if you are on Paper or on Spigot. Use the `EntitySelectorArgument.OnePlayer` if you want a `Player` object.
40
+
- The `AsyncOfflinePlayerArgument` has been replaced by the `AsyncPlayerProfileArgument`
41
+
- The `ChatArgument`, `ChatComponentArgument` and `ChatColorArgument` do no longer have any `Adventure` prefixes and return different types depending on the platform.
42
+
- The `ChatArgument` returns a `SignedMessage` object on Paper
43
+
- The `BlockStateArgument` now returns a `BlockState` object instead of a `BlockData` object
0 commit comments