Skip to content

Add documentation for CommandAPI/CommandAPI#517 #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,13 @@ const vitepressOptions: UserConfig = {
}]
}).then(_ => {
})
shiki.loadLanguage({
name: 'diff',
scopeName: 'source.diff'
}).then(_ => {
})
},
config: (md) => {
config: ( md) => {
tabsPlugin(md);
injectUpgradingPartsPlugin(md);
mermaidSpaceConverter(md);
Expand Down
1 change: 1 addition & 0 deletions docs/.vitepress/theme/upgrading/upgrading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const upgradingInfos: UpgradingInfo[] = [
{from: '9.0.1', to: '9.0.2'},
{from: '9.0.3', to: '9.1.0'},
{from: '9.2.0', to: '9.3.0'},
{from: '9.7.1', to: '10.0.0'}
]

export const keyVersions = Array.from(new Set(upgradingInfos.map(info => [info.from, info.to]).flat()));
Expand Down
128 changes: 64 additions & 64 deletions docs/en/create-commands/arguments/arguments.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,23 @@ authors:

# Adventure chat arguments

:::info
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).

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`
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.
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`
while the arguments on the Spigot chat arguments page are only available when using `commandapi-spigot-core` or `commandapi-spigot-shade`.

:::
:::info

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

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

## Adventure chat color argument

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

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

::::tip Example – Username color changing plugin

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

## Adventure chat component argument

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

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

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

## Adventure chat argument

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

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

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

```mccmd
/pbroadcast <message>
Expand Down
39 changes: 35 additions & 4 deletions docs/en/dev-setup/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,30 @@ If you've never used a build system before, I highly recommend it! It makes it e

- Add the dependency to your `pom.xml`:

:::tabs
===Paper
```xml
<dependencies>
<dependency>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-bukkit-core</artifactId>
<artifactId>commandapi-paper-core</artifactId>
<version>9.7.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
```
===Spigot
```xml
<dependencies>
<dependency>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-spigot-core</artifactId>
<version>9.7.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
```
:::

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

<div class="groovy">

:::tabs
===Paper
```groovy
dependencies {
compileOnly "dev.jorel:commandapi-bukkit-core:9.7.0"
compileOnly "dev.jorel:commandapi-paper-core:9.7.0"
}
```
===Spigot
```groovy
dependencies {
compileOnly "dev.jorel:commandapi-spigot-core:9.7.0"
}
```
:::

</div>
<div class="kts">

:::tabs
===Paper
```kotlin
dependencies {
compileOnly("dev.jorel:commandapi-bukkit-core:9.7.0")
compileOnly("dev.jorel:commandapi-paper-core:9.7.0")
}
```

===Spigot
```kotlin
dependencies {
compileOnly("dev.jorel:commandapi-spigot-core:9.7.0")
}
```
:::
</div>

</div>
Expand Down
104 changes: 94 additions & 10 deletions docs/en/dev-setup/shading.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,36 @@ public class CommandAPIConfig {

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

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

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

:::tabs
===Bukkit
```java
public class CommandAPIBukkitConfig extends CommandAPIConfig {
public abstract class CommandAPIBukkitConfig extends CommandAPIConfig {
CommandAPIBukkitConfig(JavaPlugin plugin);

CommandAPIBukkitConfig shouldHookPaperReload(boolean hooked); // Whether the CommandAPI should hook into the Paper-exclusive ServerResourcesReloadedEvent
CommandAPIBukkitConfig skipReloadDatapacks(boolean skip); // Whether the CommandAPI should reload datapacks on server load
}
```
===Paper
```java
public class CommandAPIPaperConfig extends CommandAPIBukkitConfig {
CommandAPIPaperConfig(JavaPlugin plugin);

CommandAPIPaperConfig shouldHookPaperReload(boolean hooked); // Whether the CommandAPI should hook into the Paper-exclusive ServerResourcesReloadedEvent
}
```
===Spigot
```java
public class CommandAPISpigotConfig extends CommandAPIBukkitConfig {
CommandAPISpigotConfig(JavaPlugin plugin);
}
```
:::

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

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

Expand Down Expand Up @@ -109,27 +125,55 @@ Add the CommandAPI shade dependency:

<div class="reobf">

:::tabs
===Paper
```xml
<dependencies>
<dependency>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-bukkit-shade</artifactId>
<artifactId>commandapi-paper-shade</artifactId>
<version>9.7.0</version>
</dependency>
</dependencies>
```
===Spigot
```xml
<dependencies>
<dependency>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-spigot-shade</artifactId>
<version>9.7.0</version>
</dependency>
</dependencies>
```
:::

</div>
<div class="mojmap">

:::tabs
===Paper
```xml
<dependencies>
<dependency>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-paper-shade-mojang-mapped</artifactId>
<version>9.7.0</version>
</dependency>
</dependencies>
```
===Spigot
```xml
<dependencies>
<dependency>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-bukkit-shade-mojang-mapped</artifactId>
<artifactId>commandapi-spigot-shade-mojang-mapped</artifactId>
<version>9.7.0</version>
</dependency>
</dependencies>
```
:::

</div>

You can shade the CommandAPI easily by adding the `maven-shade-plugin` to your build sequence:
Expand Down Expand Up @@ -220,37 +264,77 @@ Next, we declare our dependencies:
<div class="groovy">
<div class="reobf">

:::tabs
===Paper
```groovy
dependencies {
implementation "dev.jorel:commandapi-paper-shade:9.7.0"
}
```
===Spigot
```groovy
dependencies {
implementation "dev.jorel:commandapi-bukkit-shade:9.7.0"
implementation "dev.jorel:commandapi-spigot-shade:9.7.0"
}
```
:::

</div>
<div class="mojmap">

:::tabs
===Paper
```groovy
dependencies {
implementation "dev.jorel:commandapi-bukkit-shade-mojang-mapped:9.7.0"
implementation "dev.jorel:commandapi-paper-shade-mojang-mapped:9.7.0"
}
```
===Spigot
```groovy
dependencies {
implementation "dev.jorel:commandapi-spigot-shade-mojang-mapped:9.7.0"
}
```
:::

</div>
</div>
<div class="kts">
<div class="reobf">

:::tabs
===Paper
```kotlin
dependencies {
implementation("dev.jorel:commandapi-bukkit-shade:9.7.0")
implementation("dev.jorel:commandapi-paper-shade:9.7.0")
}
```
===Spigot
```kotlin
dependencies {
implementation("dev.jorel:commandapi-spigot-shade:9.7.0")
}
```
:::

</div>
<div class="mojmap">

:::tabs
===Paper
```kotlin
dependencies {
implementation("dev.jorel:commandapi-bukkit-shade-mojang-mapped:9.7.0")
implementation("dev.jorel:commandapi-paper-shade-mojang-mapped:9.7.0")
}
```
===Spigot
```kotlin
dependencies {
implementation("dev.jorel:commandapi-spigot-shade-mojang-mapped:9.7.0")
}
```
:::

</div>
</div>

Expand Down
Loading