Skip to content

Commit 8e2b800

Browse files
committed
Add documentation for CommandAPI/CommandAPI#517
1 parent f6aa49d commit 8e2b800

File tree

8 files changed

+286
-98
lines changed

8 files changed

+286
-98
lines changed

docs/.vitepress/theme/upgrading/upgrading.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export const upgradingInfos: UpgradingInfo[] = [
1919
{from: '9.0.3', to: '9.1.0'},
2020
{from: '9.2.0', to: '9.3.0'},
2121
{from: '9.7.0', to: '10.0.0'},
22+
{from: '10.1.2', to: '11.0.0'}
2223
]
2324

2425
export const keyVersions = Array.from(new Set(upgradingInfos.map(info => [info.from, info.to]).flat()));

docs/en/create-commands/arguments/arguments.md

Lines changed: 64 additions & 64 deletions
Large diffs are not rendered by default.

docs/en/create-commands/arguments/types/chat/adventure-chat-arguments.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,23 @@ authors:
88

99
# Adventure chat arguments
1010

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).
1212

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`.
1416

15-
:::
17+
:::info
1618

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`.
1820

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+
:::
2022

2123
## Adventure chat color argument
2224

2325
![Chatcolor argument in-game, displaying a list of Minecraft chat colors](/images/arguments/chatcolor.png)
2426

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`.
2628

2729
::::tip Example – Username color changing plugin
2830

@@ -47,7 +49,7 @@ We then use the `ChatColorArgument` to change the player's name color:
4749

4850
## Adventure chat component argument
4951

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.
5153

5254
::::tip Example – Opening a book with raw JSON content
5355

@@ -72,11 +74,11 @@ We can construct a book using the Adventure API's `Book.book(Component, Componen
7274

7375
## Adventure chat argument
7476

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`.
7678

7779
::::tip Example – Sending personalized messages to players
7880

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:
8082

8183
```mccmd
8284
/pbroadcast <message>

docs/en/dev-setup/setup.md

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,30 @@ If you've never used a build system before, I highly recommend it! It makes it e
4646
4747
- Add the dependency to your `pom.xml`:
4848

49+
:::tabs
50+
===Paper
4951
```xml
5052
<dependencies>
5153
<dependency>
5254
<groupId>dev.jorel</groupId>
53-
<artifactId>commandapi-bukkit-core</artifactId>
55+
<artifactId>commandapi-paper-core</artifactId>
5456
<version>11.0.0-SNAPSHOT</version>
5557
<scope>provided</scope>
5658
</dependency>
5759
</dependencies>
5860
```
61+
===Spigot
62+
```xml
63+
<dependencies>
64+
<dependency>
65+
<groupId>dev.jorel</groupId>
66+
<artifactId>commandapi-spigot-core</artifactId>
67+
<version>11.0.0-SNAPSHOT</version>
68+
<scope>provided</scope>
69+
</dependency>
70+
</dependencies>
71+
```
72+
:::
5973

6074
</div>
6175
<div class="gradle">
@@ -88,21 +102,38 @@ If you've never used a build system before, I highly recommend it! It makes it e
88102

89103
<div class="groovy">
90104

105+
:::tabs
106+
===Paper
91107
```groovy
92108
dependencies {
93-
compileOnly "dev.jorel:commandapi-bukkit-core:11.0.0-SNAPSHOT"
109+
compileOnly "dev.jorel:commandapi-paper-core:11.0.0-SNAPSHOT"
94110
}
95111
```
112+
===Spigot
113+
```groovy
114+
dependencies {
115+
compileOnly "dev.jorel:commandapi-spigot-core:11.0.0-SNAPSHOT"
116+
}
117+
```
118+
:::
96119

97120
</div>
98121
<div class="kts">
99122

123+
:::tabs
124+
===Paper
100125
```kotlin
101126
dependencies {
102-
compileOnly("dev.jorel:commandapi-bukkit-core:11.0.0-SNAPSHOT")
127+
compileOnly("dev.jorel:commandapi-paper-core:11.0.0-SNAPSHOT")
103128
}
104129
```
105-
130+
===Spigot
131+
```kotlin
132+
dependencies {
133+
compileOnly("dev.jorel:commandapi-spigot-core:11.0.0-SNAPSHOT")
134+
}
135+
```
136+
:::
106137
</div>
107138

108139
</div>

docs/en/dev-setup/shading.md

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,32 +37,44 @@ The `onLoad(CommandAPIConfig)` method initializes the CommandAPI's loading seque
3737
public class CommandAPIConfig {
3838
CommandAPIConfig verboseOutput(boolean value); // Enables verbose logging
3939
CommandAPIConfig silentLogs(boolean value); // Disables ALL logging (except errors)
40-
CommandAPIConfig useLatestNMSVersion(boolean value); // Whether the latest NMS implementation should be used or not
41-
CommandAPIConfig beLenientForMinorVersions(boolean value); // Whether the CommandAPI should be more lenient with minor Minecraft versions
42-
CommandAPIConfig missingExecutorImplementationMessage(String value); // Set message to display when executor implementation is missing
4340
CommandAPIConfig dispatcherFile(File file); // If not null, the CommandAPI will create a JSON file with Brigadier's command tree
4441
CommandAPIConfig setNamespace(String namespace); // The namespace to use when the CommandAPI registers a command
45-
46-
<T> CommandAPIConfig initializeNBTAPI(Class<T> nbtContainerClass, Function<Object, T> nbtContainerConstructor); // Initializes hooks with an NBT API. See NBT arguments documentation page for more info
4742
}
4843
```
4944

5045
The `CommandAPIConfig` class follows a typical builder pattern (without you having to run `.build()` at the end), which lets you easily construct configuration instances.
5146

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.
5348

5449
<!-- TODO: Add tabs and explanations for other platforms -->
5550

51+
:::tabs
52+
===Bukkit
5653
```java
57-
public class CommandAPIBukkitConfig extends CommandAPIConfig {
58-
CommandAPIBukkitConfig(JavaPlugin plugin);
54+
public abstract class CommandAPIBukkitConfig extends CommandAPIConfig {
55+
CommandAPIBukkitConfig useLatestNMSVersion(boolean value); // Whether the latest NMS implementation should be used or not
56+
CommandAPIBukkitConfig beLenientForMinorVersions(boolean value); // Whether the CommandAPI should be more lenient with minor Minecraft versions
57+
CommandAPIBukkitConfig missingExecutorImplementationMessage(String value); // Set message to display when executor implementation is missing
58+
<T> CommandAPIConfig initializeNBTAPI(Class<T> nbtContainerClass, Function<Object, T> nbtContainerConstructor); // Initializes hooks with an NBT API. See NBT arguments documentation page for more info
59+
}
60+
```
61+
===Paper
62+
```java
63+
public class CommandAPIPaperConfig extends CommandAPIBukkitConfig {
64+
CommandAPIPaperConfig(LifecycleEventOwner lifecycleEventOwner);
65+
}
66+
```
67+
===Spigot
68+
```java
69+
public class CommandAPISpigotConfig extends CommandAPIBukkitConfig {
70+
CommandAPISpigotConfig(JavaPlugin plugin);
5971

60-
CommandAPIBukkitConfig shouldHookPaperReload(boolean hooked); // Whether the CommandAPI should hook into the Paper-exclusive ServerResourcesReloadedEvent
61-
CommandAPIBukkitConfig skipReloadDatapacks(boolean skip); // Whether the CommandAPI should reload datapacks on server load
72+
CommandAPISpigotConfig skipReloadDatapacks(boolean skip); // Whether the CommandAPI should reload datapacks on server load
6273
}
6374
```
75+
:::
6476

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.
6678

6779
For example, to load the CommandAPI on Bukkit with all logging disabled, you can use the following:
6880

@@ -112,23 +124,25 @@ Add the CommandAPI shade dependency:
112124
<dependencies>
113125
<dependency>
114126
<groupId>dev.jorel</groupId>
115-
<artifactId>commandapi-bukkit-shade</artifactId>
127+
<artifactId>commandapi-spigot-shade</artifactId>
116128
<version>11.0.0-SNAPSHOT</version>
117129
</dependency>
118130
</dependencies>
119131
```
132+
120133
</div>
121134
<div class="mojmap">
122135

123136
```xml
124137
<dependencies>
125138
<dependency>
126139
<groupId>dev.jorel</groupId>
127-
<artifactId>commandapi-bukkit-shade-mojang-mapped</artifactId>
140+
<artifactId>commandapi-paper-shade</artifactId>
128141
<version>11.0.0-SNAPSHOT</version>
129142
</dependency>
130143
</dependencies>
131144
```
145+
132146
</div>
133147

134148
You can shade the CommandAPI easily by adding the `maven-shade-plugin` to your build sequence:
@@ -221,35 +235,39 @@ Next, we declare our dependencies:
221235

222236
```groovy
223237
dependencies {
224-
implementation "dev.jorel:commandapi-bukkit-shade:11.0.0-SNAPSHOT"
238+
implementation "dev.jorel:commandapi-spigot-shade:11.0.0-SNAPSHOT"
225239
}
226240
```
241+
227242
</div>
228243
<div class="mojmap">
229244

230245
```groovy
231246
dependencies {
232-
implementation "dev.jorel:commandapi-bukkit-shade-mojang-mapped:11.0.0-SNAPSHOT"
247+
implementation "dev.jorel:commandapi-paper-shade:11.0.0-SNAPSHOT"
233248
}
234249
```
250+
235251
</div>
236252
</div>
237253
<div class="kts">
238254
<div class="reobf">
239255

240256
```kotlin
241257
dependencies {
242-
implementation("dev.jorel:commandapi-bukkit-shade:11.0.0-SNAPSHOT")
258+
implementation("dev.jorel:commandapi-spigot-shade:11.0.0-SNAPSHOT")
243259
}
244260
```
261+
245262
</div>
246263
<div class="mojmap">
247264

248265
```kotlin
249266
dependencies {
250-
implementation("dev.jorel:commandapi-bukkit-shade-mojang-mapped:11.0.0-SNAPSHOT")
267+
implementation("dev.jorel:commandapi-paper-shade:11.0.0-SNAPSHOT")
251268
}
252269
```
270+
253271
</div>
254272
</div>
255273

docs/en/kotlin-dsl/intro.md

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,34 @@ This DSL provides many methods to easily add arguments to your command structure
1515

1616
## Installing the DSL
1717

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:
1919

2020
### Adding the dependency
2121

2222
<div class="maven">
2323

24+
:::tabs
25+
===Paper
2426
```xml
2527
<dependencies>
2628
<dependency>
2729
<groupId>dev.jorel</groupId>
28-
<artifactId>commandapi-bukkit-kotlin</artifactId>
30+
<artifactId>commandapi-kotlin-paper</artifactId>
2931
<version>11.0.0-SNAPSHOT</version>
3032
</dependency>
3133
</dependencies>
3234
```
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+
:::
3346

3447
Next, you need to add Kotlin to your project. For this, you first need to add the dependency:
3548

@@ -104,20 +117,38 @@ Next, you need to add the dependency:
104117

105118
<div class="groovy">
106119

120+
:::tabs
121+
===Paper
107122
```groovy
108123
dependencies {
109-
implementation "dev.jorel:commandapi-bukkit-kotlin:11.0.0-SNAPSHOT"
124+
implementation "dev.jorel:commandapi-kotlin-paper:11.0.0"
110125
}
111126
```
127+
===Spigot
128+
```groovy
129+
dependencies {
130+
implementation "dev.jorel:commandapi-kotlin-spigot:11.0.0"
131+
}
132+
```
133+
:::
112134

113135
</div>
114136
<div class="kts">
115137

138+
:::tabs
139+
===Paper
140+
```kotlin
141+
dependencies {
142+
implementation("dev.jorel:commandapi-kotlin-paper:11.0.0")
143+
}
144+
```
145+
===Spigot
116146
```kotlin
117147
dependencies {
118-
implementation("dev.jorel:commandapi-bukkit-kotlin:11.0.0-SNAPSHOT")
148+
implementation("dev.jorel:commandapi-kotlin-spigot:11.0.0")
119149
}
120150
```
151+
:::
121152

122153
</div>
123154

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
### CommandAPI restructure
2+
3+
#### General module changes
4+
5+
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&lt;PlayerProfile&gt;`. 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

Comments
 (0)