diff --git a/commandapi-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java b/commandapi-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java index ba8164a717..91d43c931b 100644 --- a/commandapi-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java +++ b/commandapi-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java @@ -28,6 +28,7 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.suggestion.Suggestions; import com.mojang.brigadier.tree.LiteralCommandNode; +import de.tr7zw.changeme.nbtapi.NBTContainer; import dev.jorel.commandapi.Brigadier; import dev.jorel.commandapi.BukkitTooltip; import dev.jorel.commandapi.CommandAPI; @@ -68,6 +69,7 @@ import dev.jorel.commandapi.arguments.MapArgumentBuilder; import dev.jorel.commandapi.arguments.MathOperationArgument; import dev.jorel.commandapi.arguments.MultiLiteralArgument; +import dev.jorel.commandapi.arguments.NBTCompoundArgument; import dev.jorel.commandapi.arguments.ObjectiveArgument; import dev.jorel.commandapi.arguments.ObjectiveCriteriaArgument; import dev.jorel.commandapi.arguments.ParticleArgument; @@ -731,6 +733,19 @@ void argument_multiLiteral() { /* ANCHOR_END: argumentMultiLiteral1 */ } +void argument_nbt2() { +/* ANCHOR: argumentNBT2 */ +new CommandAPICommand("award") + .withArguments(new NBTCompoundArgument("nbt")) + .executes((sender, args) -> { + NBTContainer nbt = (NBTContainer) args.get("nbt"); + + // Do something with "nbt" here... + }) + .register(); +/* ANCHOR_END: argumentNBT2 */ +} + void argument_objectives() { /* ANCHOR: argumentObjectives1 */ new CommandAPICommand("sidebar") diff --git a/commandapi-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt b/commandapi-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt index db098cd357..7c1c5baa21 100644 --- a/commandapi-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt +++ b/commandapi-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt @@ -576,6 +576,19 @@ CommandAPICommand("gamemode") /* ANCHOR_END: argumentMultiLiteral1 */ } +fun argument_nbt2() { +/* ANCHOR: argumentNBT2 */ +CommandAPICommand("award") + .withArguments(NBTCompoundArgument("nbt")) + .executes(CommandExecutor { _, args -> + val nbt = args["nbt"] as NBTContainer + + // Do something with "nbt" here... + }) + .register() +/* ANCHOR_END: argumentNBT2 */ +} + fun argument_objectives() { /* ANCHOR: argumentObjectives1 */ CommandAPICommand("sidebar") diff --git a/commandapi-platforms/commandapi-bukkit/commandapi-bukkit-core/src/main/java/dev/jorel/commandapi/CommandAPIBukkitConfig.java b/commandapi-platforms/commandapi-bukkit/commandapi-bukkit-core/src/main/java/dev/jorel/commandapi/CommandAPIBukkitConfig.java index fccbc43569..4380161bfe 100644 --- a/commandapi-platforms/commandapi-bukkit/commandapi-bukkit-core/src/main/java/dev/jorel/commandapi/CommandAPIBukkitConfig.java +++ b/commandapi-platforms/commandapi-bukkit/commandapi-bukkit-core/src/main/java/dev/jorel/commandapi/CommandAPIBukkitConfig.java @@ -11,7 +11,6 @@ public abstract class CommandAPIBukkitConfig JavaPlugin plugin; // Default configuration - boolean shouldHookPaperReload = true; boolean skipReloadDatapacks = false; /** @@ -70,6 +69,11 @@ public T setNamespace(String namespace) { return super.setNamespace(namespace); } + public T skipReloadDatapacks(boolean skip) { + this.skipReloadDatapacks = skip; + return instance(); + } + @Override public abstract T instance(); } diff --git a/commandapi-platforms/commandapi-paper/commandapi-paper-core/src/main/java/dev/jorel/commandapi/CommandAPIPaperConfig.java b/commandapi-platforms/commandapi-paper/commandapi-paper-core/src/main/java/dev/jorel/commandapi/CommandAPIPaperConfig.java index bcc6e1af54..8a6355671d 100644 --- a/commandapi-platforms/commandapi-paper/commandapi-paper-core/src/main/java/dev/jorel/commandapi/CommandAPIPaperConfig.java +++ b/commandapi-platforms/commandapi-paper/commandapi-paper-core/src/main/java/dev/jorel/commandapi/CommandAPIPaperConfig.java @@ -31,8 +31,7 @@ public CommandAPIPaperConfig shouldHookPaperReload(boolean hooked) { * @return this CommandAPIBukkitConfig */ public CommandAPIPaperConfig skipReloadDatapacks(boolean skip) { - this.skipReloadDatapacks = skip; - return this; + return super.skipReloadDatapacks(skip); } @Override diff --git a/commandapi-platforms/commandapi-paper/commandapi-paper-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java b/commandapi-platforms/commandapi-paper/commandapi-paper-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java index e09832d38e..63a31fd847 100644 --- a/commandapi-platforms/commandapi-paper/commandapi-paper-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java +++ b/commandapi-platforms/commandapi-paper/commandapi-paper-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java @@ -76,19 +76,6 @@ public void onLoad() { ); } /* ANCHOR_END: argumentNBT1 */ - -void argument_nbt2() { -/* ANCHOR: argumentNBT2 */ -new CommandAPICommand("award") - .withArguments(new NBTCompoundArgument("nbt")) - .executes((sender, args) -> { - NBTContainer nbt = (NBTContainer) args.get("nbt"); - - // Do something with "nbt" here... - }) - .register(); -/* ANCHOR_END: argumentNBT2 */ -} } void chatPreview() { @@ -158,8 +145,8 @@ public void onEnable() { @Override public void onDisable() { - CommandAPI.onDisable(); - } + CommandAPI.onDisable(); + } } /* ANCHOR_END: setupShading2 */ diff --git a/commandapi-platforms/commandapi-paper/commandapi-paper-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt b/commandapi-platforms/commandapi-paper/commandapi-paper-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt index da3ceacf8b..e5f8003e59 100644 --- a/commandapi-platforms/commandapi-paper/commandapi-paper-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt +++ b/commandapi-platforms/commandapi-paper/commandapi-paper-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt @@ -73,19 +73,6 @@ override fun onLoad() { } /* ANCHOR_END: argumentNBT1 */ -fun argument_nbt2() { - /* ANCHOR: argumentNBT2 */ - CommandAPICommand("award") - .withArguments(NBTCompoundArgument("nbt")) - .executes(CommandExecutor { _, args -> - val nbt = args["nbt"] as NBTContainer - - // Do something with "nbt" here... - }) - .register() - /* ANCHOR_END: argumentNBT2 */ -} - } fun chatPreview() { @@ -127,9 +114,9 @@ class setupShading { val plugin: JavaPlugin = object : JavaPlugin() {} fun setupShading1() { - /* ANCHOR: setupShading1 */ - CommandAPI.onLoad(CommandAPIPaperConfig(plugin).silentLogs(true)) - /* ANCHOR_END: setupShading1 */ +/* ANCHOR: setupShading1 */ +CommandAPI.onLoad(CommandAPIPaperConfig(plugin).silentLogs(true)) +/* ANCHOR_END: setupShading1 */ } /* ANCHOR: setupShading2 */ diff --git a/commandapi-platforms/commandapi-paper/commandapi-paper-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/ExamplesKotlinDSL.kt b/commandapi-platforms/commandapi-paper/commandapi-paper-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/ExamplesKotlinDSL.kt index 7fe88a0288..08a72c561d 100644 --- a/commandapi-platforms/commandapi-paper/commandapi-paper-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/ExamplesKotlinDSL.kt +++ b/commandapi-platforms/commandapi-paper/commandapi-paper-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/ExamplesKotlinDSL.kt @@ -1,10 +1,12 @@ package dev.jorel.commandapi.examples.kotlin +import de.tr7zw.changeme.nbtapi.NBTContainer import dev.jorel.commandapi.kotlindsl.anyExecutor import dev.jorel.commandapi.kotlindsl.chatArgument import dev.jorel.commandapi.kotlindsl.chatColorArgument import dev.jorel.commandapi.kotlindsl.chatComponentArgument import dev.jorel.commandapi.kotlindsl.commandAPICommand +import dev.jorel.commandapi.kotlindsl.nbtCompoundArgument import dev.jorel.commandapi.kotlindsl.playerArgument import dev.jorel.commandapi.kotlindsl.playerExecutor import dev.jorel.commandapi.kotlindsl.stringArgument @@ -62,4 +64,17 @@ commandAPICommand("pbroadcast") { /* ANCHOR_END: argumentChatAdventure3 */ } +fun argument_nbt() { +/* ANCHOR: argumentNBT1 */ +commandAPICommand("award") { + nbtCompoundArgument("nbt") + anyExecutor { _, args -> + val nbt = args["nbt"] as NBTContainer + + // Do something with "nbt" here... + } +} +/* ANCHOR_END: argumentNBT1 */ +} + } \ No newline at end of file diff --git a/commandapi-platforms/commandapi-spigot/commandapi-spigot-core/src/main/java/dev/jorel/commandapi/CommandAPISpigotConfig.java b/commandapi-platforms/commandapi-spigot/commandapi-spigot-core/src/main/java/dev/jorel/commandapi/CommandAPISpigotConfig.java index 5229050869..4134f76755 100644 --- a/commandapi-platforms/commandapi-spigot/commandapi-spigot-core/src/main/java/dev/jorel/commandapi/CommandAPISpigotConfig.java +++ b/commandapi-platforms/commandapi-spigot/commandapi-spigot-core/src/main/java/dev/jorel/commandapi/CommandAPISpigotConfig.java @@ -15,8 +15,7 @@ public CommandAPISpigotConfig(JavaPlugin plugin) { * @return this CommandAPIBukkitConfig */ public CommandAPISpigotConfig skipReloadDatapacks(boolean skip) { - this.skipReloadDatapacks = skip; - return this; + return super.skipReloadDatapacks(skip); } @Override diff --git a/commandapi-platforms/commandapi-spigot/commandapi-spigot-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java b/commandapi-platforms/commandapi-spigot/commandapi-spigot-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java index 0a1675e6ae..00b67586c4 100644 --- a/commandapi-platforms/commandapi-spigot/commandapi-spigot-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java +++ b/commandapi-platforms/commandapi-spigot/commandapi-spigot-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java @@ -76,19 +76,6 @@ public void onLoad() { ); } /* ANCHOR_END: argumentNBT1 */ - -void argument_nbt2() { - /* ANCHOR: argumentNBT2 */ - new CommandAPICommand("award") - .withArguments(new NBTCompoundArgument("nbt")) - .executes((sender, args) -> { - NBTContainer nbt = (NBTContainer) args.get("nbt"); - - // Do something with "nbt" here... - }) - .register(); - /* ANCHOR_END: argumentNBT2 */ -} } void chatPreview() { @@ -110,7 +97,7 @@ void chatPreview() { .register(); /* ANCHOR_END: chatPreview1 */ -/* ANCHOR: chatPreview3 */ +/* ANCHOR: chatPreview2 */ new CommandAPICommand("broadcast") .withArguments(new ChatArgument("message").usePreview(true).withPreview(info -> { // Convert parsed BaseComponent[] to plain text @@ -123,7 +110,7 @@ void chatPreview() { Bukkit.spigot().broadcast((BaseComponent[]) args.get("message")); }) .register(); -/* ANCHOR_END: chatPreview3 */ +/* ANCHOR_END: chatPreview2 */ } class setupShading { @@ -131,9 +118,9 @@ class setupShading { }; { - /* ANCHOR: setupShading1 */ - CommandAPI.onLoad(new CommandAPISpigotConfig(plugin).silentLogs(true)); - /* ANCHOR_END: setupShading1 */ +/* ANCHOR: setupShading1 */ +CommandAPI.onLoad(new CommandAPISpigotConfig(plugin).silentLogs(true)); +/* ANCHOR_END: setupShading1 */ } /* ANCHOR: setupShading2 */ diff --git a/commandapi-platforms/commandapi-spigot/commandapi-spigot-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt b/commandapi-platforms/commandapi-spigot/commandapi-spigot-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt index f8e6bb3ebc..a6772779b7 100644 --- a/commandapi-platforms/commandapi-spigot/commandapi-spigot-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt +++ b/commandapi-platforms/commandapi-spigot/commandapi-spigot-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt @@ -76,20 +76,6 @@ override fun onLoad() { ) } /* ANCHOR_END: argumentNBT1 */ - -fun argument_nbt2() { - /* ANCHOR: argumentNBT2 */ - CommandAPICommand("award") - .withArguments(NBTCompoundArgument("nbt")) - .executes(CommandExecutor { _, args -> - val nbt = args["nbt"] as NBTContainer - - // Do something with "nbt" here... - }) - .register() - /* ANCHOR_END: argumentNBT2 */ -} - } fun chatPreview() { @@ -132,9 +118,9 @@ class setupShading { val plugin: JavaPlugin = object : JavaPlugin() {} fun setupShading1() { - /* ANCHOR: setupShading1 */ - CommandAPI.onLoad(CommandAPISpigotConfig(plugin).silentLogs(true)) - /* ANCHOR_END: setupShading1 */ +/* ANCHOR: setupShading1 */ +CommandAPI.onLoad(CommandAPISpigotConfig(plugin).silentLogs(true)) +/* ANCHOR_END: setupShading1 */ } /* ANCHOR: setupShading2 */ diff --git a/commandapi-platforms/commandapi-spigot/commandapi-spigot-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/ExamplesKotlinDSL.kt b/commandapi-platforms/commandapi-spigot/commandapi-spigot-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/ExamplesKotlinDSL.kt index fc94d820fa..22e0715ef2 100644 --- a/commandapi-platforms/commandapi-spigot/commandapi-spigot-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/ExamplesKotlinDSL.kt +++ b/commandapi-platforms/commandapi-spigot/commandapi-spigot-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/ExamplesKotlinDSL.kt @@ -1,5 +1,6 @@ package dev.jorel.commandapi.examples.kotlin +import de.tr7zw.changeme.nbtapi.NBTContainer import dev.jorel.commandapi.executors.CommandArguments import dev.jorel.commandapi.kotlindsl.* import net.md_5.bungee.api.chat.BaseComponent diff --git a/docssrc/src/argument_chat_adventure.md b/docssrc/src/argument_chat_adventure.md index 0250b5447e..796217cd8e 100644 --- a/docssrc/src/argument_chat_adventure.md +++ b/docssrc/src/argument_chat_adventure.md @@ -1,12 +1,14 @@ # Adventure chat arguments -> **Developer's Note:** -> -> 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` - 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 of 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). 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](./argument_chat_spigot.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`. + +> **Developer's Note:** +> +> The three following classes, `ChatColorArgument`, `ChatComponentArgument` and `ChatArgument` 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` ----- @@ -14,7 +16,7 @@ Since this functions very similar to the Spigot chat arguments, this page won't ![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`.
@@ -31,15 +33,15 @@ We then use the `ChatColorArgument` to change the player's name color:
```java,Java -{{#include ../../commandapi-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java:argumentChatAdventure1}} +{{#include ../../commandapi-platforms/commandapi-paper/commandapi-paper-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java:argumentChatAdventure1}} ``` ```kotlin,Kotlin -{{#include ../../commandapi-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt:argumentChatAdventure1}} +{{#include ../../commandapi-platforms/commandapi-paper/commandapi-paper-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt:argumentChatAdventure1}} ``` ```kotlin,Kotlin_DSL -{{#include ../../commandapi-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/ExamplesKotlinDSL.kt:argumentChatAdventure1}} +{{#include ../../commandapi-platforms/commandapi-paper/commandapi-paper-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/ExamplesKotlinDSL.kt:argumentChatAdventure1}} ```
@@ -50,7 +52,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.
@@ -67,15 +69,15 @@ We can construct a book using the Adventure API's `Book.book(Component, Componen
```java,Java -{{#include ../../commandapi-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java:argumentChatAdventure2}} +{{#include ../../commandapi-platforms/commandapi-paper/commandapi-paper-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java:argumentChatAdventure2}} ``` ```kotlin,Kotlin -{{#include ../../commandapi-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt:argumentChatAdventure2}} +{{#include ../../commandapi-platforms/commandapi-paper/commandapi-paper-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt:argumentChatAdventure2}} ``` ```kotlin,Kotlin_DSL -{{#include ../../commandapi-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/ExamplesKotlinDSL.kt:argumentChatAdventure2}} +{{#include ../../commandapi-platforms/commandapi-paper/commandapi-paper-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/ExamplesKotlinDSL.kt:argumentChatAdventure2}} ```
@@ -86,13 +88,13 @@ 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`.
### 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 @@ -103,15 +105,15 @@ In order to broadcast an Adventure `Component` to all players on the server, we
```java,Java -{{#include ../../commandapi-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java:argumentChatAdventure3}} +{{#include ../../commandapi-platforms/commandapi-paper/commandapi-paper-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java:argumentChatAdventure3}} ``` ```kotlin,Kotlin -{{#include ../../commandapi-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt:argumentChatAdventure3}} +{{#include ../../commandapi-platforms/commandapi-paper/commandapi-paper-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt:argumentChatAdventure3}} ``` ```kotlin,Kotlin_DSL -{{#include ../../commandapi-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/ExamplesKotlinDSL.kt:argumentChatAdventure3}} +{{#include ../../commandapi-platforms/commandapi-paper/commandapi-paper-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/ExamplesKotlinDSL.kt:argumentChatAdventure3}} ```
diff --git a/docssrc/src/argument_chat_spigot.md b/docssrc/src/argument_chat_spigot.md index ce7336e39f..381a32a159 100644 --- a/docssrc/src/argument_chat_spigot.md +++ b/docssrc/src/argument_chat_spigot.md @@ -21,15 +21,15 @@ We then use the `ChatColorArgument` to change the player's name color:
```java,Java -{{#include ../../commandapi-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java:argumentChatSpigot1}} +{{#include ../../commandapi-platforms/commandapi-spigot/commandapi-spigot-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java:argumentChatSpigot1}} ``` ```kotlin,Kotlin -{{#include ../../commandapi-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt:argumentChatSpigot1}} +{{#include ../../commandapi-platforms/commandapi-spigot/commandapi-spigot-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt:argumentChatSpigot1}} ``` ```kotlin,Kotlin_DSL -{{#include ../../commandapi-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/ExamplesKotlinDSL.kt:argumentChatSpigot1}} +{{#include ../../commandapi-platforms/commandapi-spigot/commandapi-spigot-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/ExamplesKotlinDSL.kt:argumentChatSpigot1}} ```
@@ -121,15 +121,15 @@ Now we can create our book command. We use the player as the main target by usin
```java,Java -{{#include ../../commandapi-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java:argumentChatSpigot2}} +{{#include ../../commandapi-platforms/commandapi-spigot/commandapi-spigot-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java:argumentChatSpigot2}} ``` ```kotlin,Kotlin -{{#include ../../commandapi-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt:argumentChatSpigot2}} +{{#include ../../commandapi-platforms/commandapi-spigot/commandapi-spigot-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt:argumentChatSpigot2}} ``` ```kotlin,Kotlin_DSL -{{#include ../../commandapi-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/ExamplesKotlinDSL.kt:argumentChatSpigot2}} +{{#include ../../commandapi-platforms/commandapi-spigot/commandapi-spigot-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/ExamplesKotlinDSL.kt:argumentChatSpigot2}} ```
@@ -167,15 +167,15 @@ _Bob_ would receive the message "Hello Bob", whereas _Michael_ would receive the
```java,Java -{{#include ../../commandapi-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java:argumentChatSpigot3}} +{{#include ../../commandapi-platforms/commandapi-spigot/commandapi-spigot-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java:argumentChatSpigot3}} ``` ```kotlin,Kotlin -{{#include ../../commandapi-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt:argumentChatSpigot3}} +{{#include ../../commandapi-platforms/commandapi-spigot/commandapi-spigot-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt:argumentChatSpigot3}} ``` ```kotlin,Kotlin_DSL -{{#include ../../commandapi-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/ExamplesKotlinDSL.kt:argumentChatSpigot3}} +{{#include ../../commandapi-platforms/commandapi-spigot/commandapi-spigot-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/ExamplesKotlinDSL.kt:argumentChatSpigot3}} ```
diff --git a/docssrc/src/argument_nbt.md b/docssrc/src/argument_nbt.md index d43d306194..ce387489e5 100644 --- a/docssrc/src/argument_nbt.md +++ b/docssrc/src/argument_nbt.md @@ -38,12 +38,20 @@ Now, we can configure the CommandAPI using the `CommandAPI.onLoad()` method to u
-```java,Java -{{#include ../../commandapi-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java:argumentNBT1}} +```java,Java_(Paper) +{{#include ../../commandapi-platforms/commandapi-paper/commandapi-paper-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java:argumentNBT1}} ``` -```kotlin,Kotlin -{{#include ../../commandapi-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt:argumentNBT1}} +```java,Java_(Spigot) +{{#include ../../commandapi-platforms/commandapi-spigot/commandapi-spigot-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java:argumentNBT1}} +``` + +```kotlin,Kotlin_(Paper) +{{#include ../../commandapi-platforms/commandapi-paper/commandapi-paper-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt:argumentNBT1}} +``` + +```kotlin,Kotlin_(Spigot) +{{#include ../../commandapi-platforms/commandapi-spigot/commandapi-spigot-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt:argumentNBT1}} ```
diff --git a/docssrc/src/arguments.md b/docssrc/src/arguments.md index ad3bfa92f7..2791c44660 100644 --- a/docssrc/src/arguments.md +++ b/docssrc/src/arguments.md @@ -95,67 +95,65 @@ To access arguments, they have to be casted to the type that the argument repres The type to cast each argument (declared in the `dev.jorel.commandapi.arguments` package) is listed below: -| Argument class | Data type | -|---------------------------------------------------------------------------------------------------:|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| [`AngleArgument`](./argument_angle.md) | `float` | -| [`AdvancementArgument`](./advancementargument.md) | `org.bukkit.advancement.Advancement` | -| [`AdventureChatArgument`](./argument_chat_adventure.md#adventure-chat-argument) | `net.kyori.adventure.text.Component` | -| [`AdventureChatColorArgument`](./argument_chat_adventure.md#adventure-chat-color-argument) | `net.kyori.adventure.text.format.NamedTextColor` | -| [`AdventureChatComponentArgument`](./argument_chat_adventure.md#adventure-chat-component-argument) | `net.kyori.adventure.text.Component` | -| [`AxisArgument`](./argument_axis.md) | `java.util.EnumSet` | -| [`BiomeArgument`](./argument_biome.md) | `org.bukkit.block.Biome` | -| [`BiomeArgument.NamespacedKey`](./argument_biome.md) | `org.bukkit.NamespacedKey` | -| [`BlockPredicateArgument`](./argument_blockpredicate.md) | `java.util.function.Predicate`
 `` | -| [`BlockStateArgument`](./argument_blockstate.md) | `org.bukkit.block.data.BlockData` | -| [`BooleanArgument`](./argument_primitives.md#boolean-arguments) | `boolean` | -| [`ChatArgument`](./argument_chat_spigot.md#chat-argument) | `net.md_5.bungee.api.chat.BaseComponent[]` | -| [`ChatColorArgument`](./argument_chats.md#chat-color-argument) | `org.bukkit.ChatColor` | -| [`ChatComponentArgument`](./argument_chat_spigot.md#chat-component-argument) | `net.md_5.bungee.api.chat.BaseComponent[]` | -| [`CommandArgument`](./argument_command.md) | `dev.jorel.commandapi.wrappers.CommandResult` | -| [`CustomArgument`](./argument_custom.md) | `T` | -| [`DoubleArgument`](./argument_primitives.md#numerical-arguments) | `double` | -| [`EnchantmentArgument`](./argument_enchantment.md) | `org.bukkit.enchantments.Enchantment` | -| [`EntitySelectorArgument.ManyEntities`](./argument_entities.md#entity-selector-argument) | `Collection` | -| [`EntitySelectorArgument.ManyPlayers`](./argument_entities.md#entity-selector-argument) | `Collection` | -| [`EntitySelectorArgument.OneEntity`](./argument_entities.md#entity-selector-argument) | `org.bukkit.entity.Entity` | -| [`EntitySelectorArgument.OnePlayer`](./argument_entities.md#entity-selector-argument) | `org.bukkit.entity.Player` | -| [`EntityTypeArgument`](./argument_entities.md#entity-type-argument) | `org.bukkit.entity.EntityType` | -| [`FloatArgument`](./argument_primitives.md#numerical-arguments) | `float` | -| [`FloatRangeArgument`](./argument_range.md#the-integerrange--floatrange-class) | `dev.jorel.commandapi.wrappers.FloatRange` | -| [`FunctionArgument`](./functionwrapper.md) | `dev.jorel.commandapi.wrappers.FunctionWrapper[]` | -| [`GreedyStringArgument`](./argument_strings.md#greedy-string-argument) | `String` | -| [`IntegerArgument`](./argument_primitives.md#numerical-arguments) | `int` | -| [`IntegerRangeArgument`](./argument_range.md#the-integerrange--floatrange-class) | `dev.jorel.commandapi.wrappers.IntegerRange` | -| [`ItemStackArgument`](./argument_itemstack.md) | `org.bukkit.inventory.ItemStack` | -| [`ItemStackPredicateArgument`](./argument_itemstackpredicate.md) | `java.util.function.Predicate`
 `` | -| [`ListArgument`](./argument_list.md) | `java.util.Collection` | -| [`LiteralArgument`](./argument_literal.md) | N/A | -| [`Location2DArgument`](./argument_locations.md#location-2d-space) | `dev.jorel.commandapi.wrappers.Location2D` | -| [`LocationArgument`](./argument_locations.md#location-3d-space) | `org.bukkit.Location` | -| [`LongArgument`](./argument_primitives.md#numerical-arguments) | `long` | -| [`LootTableArgument`](./argument_loottable.md) | `org.bukkit.loot.LootTable` | -| [`MapArgument`](./argument_map.md) | `java.util.LinkedHashMap` | -| [`MathOperationArgument`](./argument_mathoperation.md) | `dev.jorel.commandapi.wrappers.MathOperation` | -| [`MultiLiteralArgument`](./argument_multiliteral.md) | `String` | -| [`NamespacedKeyArgument`](./argument_namespacedkey.md) | `org.bukkit.NamespacedKey` | -| [`NBTCompoundArgument`](./argument_nbt.md) | The cast type changes depending on whether you're shading the CommandAPI or using the CommandAPI as a plugin:
  • Shading:
    `T` (implemented yourself)

  • Plugin:
    `dev.jorel.commandapi.nbtapi.NBTContainer`
| -| [`ObjectiveArgument`](./argument_objectives.md#objective-argument) | `org.bukkit.scoreboard.Objective` | -| [`ObjectiveCriteriaArgument`](./argument_objectives.md#objective-criteria-argument) | `String` | -| [`OfflinePlayerArgument`](./argument_entities.md#offlineplayer-argument) | `org.bukkit.OfflinePlayer` | -| [`ParticleArgument`](./argument_particles.md) | `dev.jorel.commandapi.wrappers.ParticleData` | -| [`PlayerArgument`](./argument_entities.md#player-argument) | `org.bukkit.entity.Player` | -| [`PotionEffectArgument`](./argument_potion.md) | `org.bukkit.potion.PotionEffectType` | -| [`PotionEffectArgument.NamespacedKey`](./argument_potion.md) | `org.bukkit.NamespacedKey` | -| [`RecipeArgument`](./argument_recipe.md) | The cast type changes depending on your Minecraft version:
  • Version 1.14.4 and below:
    `org.bukkit.inventory.Recipe`

  • 1.15 and above:
    `org.bukkit.inventory.ComplexRecipe`
| -| [`RotationArgument`](./argument_rotation.md) | `dev.jorel.commandapi.wrappers.Rotation` | -| [`ScoreboardSlotArgument`](./argument_scoreboards.md#scoreboard-slot-argument) | `dev.jorel.commandapi.wrappers.ScoreboardSlot` | -| [`ScoreHolderArgument.Single`](./argument_scoreboards.md#score-holder-argument) | `String` | -| [`ScoreHolderArgument.Multiple`](./argument_scoreboards.md#score-holder-argument) | `Collection` | -| [`SoundArgument`](./argument_sound.md) | `org.bukkit.Sound` | -| [`SoundArgument.NamespacedKey`](./argument_sound.md) | `org.bukkit.NamespacedKey` | -| [`StringArgument`](./argument_strings.md#string-argument) | `String` | -| [`TeamArgument`](./argument_team.md) | `org.bukkit.scoreboard.Team` | -| [`TextArgument`](./argument_strings.md#text-argument) | `String` | -| [`TimeArgument`](./argument_time.md) | `int` | -| [`UUIDArgument`](./argument_uuid.md) | `java.util.UUID` | -| [`WorldArgument`](./argument_world.md) | `org.bukkit.World` | +| Argument class | Data type | +|---------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| [`AngleArgument`](./argument_angle.md) | `float` | +| [`AdvancementArgument`](./advancementargument.md) | `org.bukkit.advancement.Advancement` | +| [`AdventureChatComponentArgument`](./argument_chat_adventure.md#adventure-chat-component-argument) | `net.kyori.adventure.text.Component` | +| [`AxisArgument`](./argument_axis.md) | `java.util.EnumSet` | +| [`BiomeArgument`](./argument_biome.md) | `org.bukkit.block.Biome` | +| [`BiomeArgument.NamespacedKey`](./argument_biome.md) | `org.bukkit.NamespacedKey` | +| [`BlockPredicateArgument`](./argument_blockpredicate.md) | `java.util.function.Predicate`
 `` | +| [`BlockStateArgument`](./argument_blockstate.md) | `org.bukkit.block.data.BlockData` | +| [`BooleanArgument`](./argument_primitives.md#boolean-arguments) | `boolean` | +| [`ChatArgument`](./argument_chat_spigot.md#chat-argument) | The cast type changes depending on the version of the CommandAPI you use:
  • `commandapi-paper-XXX`:
    `net.kyori.adventure.text.Component`

  • `commandapi-spigot-XXX`:
    `net.md_5.bungee.api.chat.BaseComponent[]`
| +| [`ChatColorArgument`](./argument_chats.md#chat-color-argument) | The cast type changes depending on the version of the CommandAPI you use:
  • `commandapi-paper-XXX`:
    `net.kyori.adventure.text.format.NamedTextFormat`

  • `commandapi-spigot-XXX`:
    `org.bukkit.ChatColor`
| +| [`ChatComponentArgument`](./argument_chat_spigot.md#chat-component-argument) | The cast type changes depending on the version of the CommandAPI you use:
  • `commandapi-paper-XXX`:
    `net.kyori.adventure.text.Component`

  • `commandapi-spigot-XXX`:
    `net.md_5.bungee.api.chat.BaseComponent[]`
| +| [`CommandArgument`](./argument_command.md) | `dev.jorel.commandapi.wrappers.CommandResult` | +| [`CustomArgument`](./argument_custom.md) | `T` | +| [`DoubleArgument`](./argument_primitives.md#numerical-arguments) | `double` | +| [`EnchantmentArgument`](./argument_enchantment.md) | `org.bukkit.enchantments.Enchantment` | +| [`EntitySelectorArgument.ManyEntities`](./argument_entities.md#entity-selector-argument) | `Collection` | +| [`EntitySelectorArgument.ManyPlayers`](./argument_entities.md#entity-selector-argument) | `Collection` | +| [`EntitySelectorArgument.OneEntity`](./argument_entities.md#entity-selector-argument) | `org.bukkit.entity.Entity` | +| [`EntitySelectorArgument.OnePlayer`](./argument_entities.md#entity-selector-argument) | `org.bukkit.entity.Player` | +| [`EntityTypeArgument`](./argument_entities.md#entity-type-argument) | `org.bukkit.entity.EntityType` | +| [`FloatArgument`](./argument_primitives.md#numerical-arguments) | `float` | +| [`FloatRangeArgument`](./argument_range.md#the-integerrange--floatrange-class) | `dev.jorel.commandapi.wrappers.FloatRange` | +| [`FunctionArgument`](./functionwrapper.md) | `dev.jorel.commandapi.wrappers.FunctionWrapper[]` | +| [`GreedyStringArgument`](./argument_strings.md#greedy-string-argument) | `String` | +| [`IntegerArgument`](./argument_primitives.md#numerical-arguments) | `int` | +| [`IntegerRangeArgument`](./argument_range.md#the-integerrange--floatrange-class) | `dev.jorel.commandapi.wrappers.IntegerRange` | +| [`ItemStackArgument`](./argument_itemstack.md) | `org.bukkit.inventory.ItemStack` | +| [`ItemStackPredicateArgument`](./argument_itemstackpredicate.md) | `java.util.function.Predicate`
 `` | +| [`ListArgument`](./argument_list.md) | `java.util.Collection` | +| [`LiteralArgument`](./argument_literal.md) | N/A | +| [`Location2DArgument`](./argument_locations.md#location-2d-space) | `dev.jorel.commandapi.wrappers.Location2D` | +| [`LocationArgument`](./argument_locations.md#location-3d-space) | `org.bukkit.Location` | +| [`LongArgument`](./argument_primitives.md#numerical-arguments) | `long` | +| [`LootTableArgument`](./argument_loottable.md) | `org.bukkit.loot.LootTable` | +| [`MapArgument`](./argument_map.md) | `java.util.LinkedHashMap` | +| [`MathOperationArgument`](./argument_mathoperation.md) | `dev.jorel.commandapi.wrappers.MathOperation` | +| [`MultiLiteralArgument`](./argument_multiliteral.md) | `String` | +| [`NamespacedKeyArgument`](./argument_namespacedkey.md) | `org.bukkit.NamespacedKey` | +| [`NBTCompoundArgument`](./argument_nbt.md) | The cast type changes depending on whether you're shading the CommandAPI or using the CommandAPI as a plugin:
  • Shading:
    `T` (implemented yourself)

  • Plugin:
    `dev.jorel.commandapi.nbtapi.NBTContainer`
| +| [`ObjectiveArgument`](./argument_objectives.md#objective-argument) | `org.bukkit.scoreboard.Objective` | +| [`ObjectiveCriteriaArgument`](./argument_objectives.md#objective-criteria-argument) | `String` | +| [`OfflinePlayerArgument`](./argument_entities.md#offlineplayer-argument) | `org.bukkit.OfflinePlayer` | +| [`ParticleArgument`](./argument_particles.md) | `dev.jorel.commandapi.wrappers.ParticleData` | +| [`PlayerArgument`](./argument_entities.md#player-argument) | `org.bukkit.entity.Player` | +| [`PotionEffectArgument`](./argument_potion.md) | `org.bukkit.potion.PotionEffectType` | +| [`PotionEffectArgument.NamespacedKey`](./argument_potion.md) | `org.bukkit.NamespacedKey` | +| [`RecipeArgument`](./argument_recipe.md) | The cast type changes depending on your Minecraft version:
  • Version 1.14.4 and below:
    `org.bukkit.inventory.Recipe`

  • 1.15 and above:
    `org.bukkit.inventory.ComplexRecipe`
| +| [`RotationArgument`](./argument_rotation.md) | `dev.jorel.commandapi.wrappers.Rotation` | +| [`ScoreboardSlotArgument`](./argument_scoreboards.md#scoreboard-slot-argument) | `dev.jorel.commandapi.wrappers.ScoreboardSlot` | +| [`ScoreHolderArgument.Single`](./argument_scoreboards.md#score-holder-argument) | `String` | +| [`ScoreHolderArgument.Multiple`](./argument_scoreboards.md#score-holder-argument) | `Collection` | +| [`SoundArgument`](./argument_sound.md) | `org.bukkit.Sound` | +| [`SoundArgument.NamespacedKey`](./argument_sound.md) | `org.bukkit.NamespacedKey` | +| [`StringArgument`](./argument_strings.md#string-argument) | `String` | +| [`TeamArgument`](./argument_team.md) | `org.bukkit.scoreboard.Team` | +| [`TextArgument`](./argument_strings.md#text-argument) | `String` | +| [`TimeArgument`](./argument_time.md) | `int` | +| [`UUIDArgument`](./argument_uuid.md) | `java.util.UUID` | +| [`WorldArgument`](./argument_world.md) | `org.bukkit.World` | diff --git a/docssrc/src/chatpreview.md b/docssrc/src/chatpreview.md index 87037d1caa..96cebf60ec 100644 --- a/docssrc/src/chatpreview.md +++ b/docssrc/src/chatpreview.md @@ -111,26 +111,26 @@ Say we wanted to make our own `/broadcast` command that allowed the user to use /broadcast ``` -Because the `ChatArgument` and `AdventureChatArgument` can support entity selectors (such as `@p`), it's best to use the `info.parsedInput()` method to handle parsed entity selectors. In our code, we use the `.withPreview()` method and take the parsed input and convert it to plain text. We then convert the plain text with `&` characters into component text to be displayed to the user. +Because the `ChatArgument` can support entity selectors (such as `@p`), it's best to use the `info.parsedInput()` method to handle parsed entity selectors. In our code, we use the `.withPreview()` method and take the parsed input and convert it to plain text. We then convert the plain text with `&` characters into component text to be displayed to the user. For execution, we do the same procedure, because the text that the user enters still has `&` characters that need to be converted into a component.
-```java,Spigot_(Java) -{{#include ../../commandapi-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java:chatPreview1}} -``` - ```java,Paper_(Java) -{{#include ../../commandapi-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java:chatPreview2}} +{{#include ../../commandapi-platforms/commandapi-paper/commandapi-paper-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java:chatPreview1}} ``` -```kotlin,Spigot_(Kotlin) -{{#include ../../commandapi-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt:chatPreview1}} +```java,Spigot_(Java) +{{#include ../../commandapi-platforms/commandapi-spigot/commandapi-spigot-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java:chatPreview1}} ``` ```kotlin,Paper_(Kotlin) -{{#include ../../commandapi-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt:chatPreview2}} +{{#include ../../commandapi-platforms/commandapi-paper/commandapi-paper-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt:chatPreview1}} +``` + +```kotlin,Spigot_(Kotlin) +{{#include ../../commandapi-platforms/commandapi-spigot/commandapi-spigot-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt:chatPreview1}} ```
@@ -151,20 +151,20 @@ By using `.usePreview(true)`, we don't have to re-translate `&` formatting codes
-```java,Spigot_(Java) -{{#include ../../commandapi-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java:chatPreview3}} -``` - ```java,Paper_(Java) -{{#include ../../commandapi-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java:chatPreview4}} +{{#include ../../commandapi-platforms/commandapi-paper/commandapi-paper-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java:chatPreview2}} ``` -```kotlin,Spigot_(Kotlin) -{{#include ../../commandapi-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt:chatPreview3}} +```java,Spigot_(Java) +{{#include ../../commandapi-platforms/commandapi-spigot/commandapi-spigot-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java:chatPreview2}} ``` ```kotlin,Paper_(Kotlin) -{{#include ../../commandapi-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt:chatPreview4}} +{{#include ../../commandapi-platforms/commandapi-paper/commandapi-paper-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt:chatPreview2}} +``` + +```kotlin,Spigot_(Kotlin) +{{#include ../../commandapi-platforms/commandapi-spigot/commandapi-spigot-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt:chatPreview2}} ```
diff --git a/docssrc/src/config.md b/docssrc/src/config.md index 950f78341c..285997e6cd 100644 --- a/docssrc/src/config.md +++ b/docssrc/src/config.md @@ -9,10 +9,18 @@ The default `config.yml` is shown below:
config.yml -```yaml -{{#include ../../commandapi-platforms/commandapi-bukkit/commandapi-bukkit-plugin/src/main/resources/config.yml}} +
+ +```yaml,Paper +{{#include ../../commandapi-platforms/commandapi-paper/commandapi-paper-plugin/src/main/resources/config.yml}} ``` +````yaml,Spigot +{{#include ../../commandapi-platforms/commandapi-spigot/commandapi-spigot-plugin/src/main/resources/config.yml}} +```` + +
+
## Configuration settings diff --git a/docssrc/src/setup_dev.md b/docssrc/src/setup_dev.md index 35307cb17f..2c39af1658 100644 --- a/docssrc/src/setup_dev.md +++ b/docssrc/src/setup_dev.md @@ -35,17 +35,32 @@ dependencies: - Add the dependency to your `pom.xml`: - ```xml +
+ + ```xml,Paper + + + dev.jorel + commandapi-paper-core + 9.6.0-SNAPSHOT + provided + + + ``` + + ```xml,Spigot dev.jorel - commandapi-bukkit-core + commandapi-spigot-core 9.6.0-SNAPSHOT provided ``` +
+ ## Using Gradle (recommended) - Add the repositories to your `build.gradle` file (the second repository is required because the CommandAPI depends on the NBT-API): @@ -59,12 +74,22 @@ dependencies: - Add the dependency to your list of dependencies in your `build.gradle` file: - ```gradle +
+ + ```gradle,Paper dependencies { - compileOnly "dev.jorel:commandapi-bukkit-core:9.6.0-SNAPSHOT" + compileOnly "dev.jorel:commandapi-paper-core:9.6.0-SNAPSHOT" } ``` + ```gradle,Spigot + dependencies { + compileOnly "dev.jorel:commandapi-spigot-core:9.6.0-SNAPSHOT" + } + ``` + +
+ ## Manually using the .jar - Download the latest CommandAPI.jar from the download page [here](https://github.com/JorelAli/CommandAPI/releases/latest) diff --git a/docssrc/src/setup_shading.md b/docssrc/src/setup_shading.md index 1b6cd34214..5eeb137147 100644 --- a/docssrc/src/setup_shading.md +++ b/docssrc/src/setup_shading.md @@ -43,31 +43,54 @@ 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 cannot be used to configure the CommandAPI directly. Instead, you must use a subclass of `CommandAPIConfig` that corresponds to the platform you are developing for. For example, when developing for Bukkit, you should use the `CommandAPIBukkitConfig` class. +However, the `CommandAPIConfig` class is abstract and cannot be used to configure the CommandAPI directly. Instead, you must use a subclass of `CommandAPIConfig` that corresponds to the platform you are developing for. For example, when developing for a Bukkit-based server, you should use the `CommandAPIPaperConfig` or the `CommandAPISpigotConfig` class. -```java -public 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 +```java,Bukkit +public abstract class CommandAPIBukkitConfig extends CommandAPIConfig { + CommandAPIBukkitConfig skipReloadDatapacks(boolean skip); // Whether the CommandAPI should skip its initial datapack reload step } ``` -In order to create a `CommandAPIBukkitConfig` object, you must give it a reference to your `JavaPlugin` instance. The CommandAPI always uses this to registers 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. +```java,Paper +public class CommandAPIPaperConfig extends CommandAPIBukkitConfig { + CommandAPIPaperConfig(JavaPlugin plugin); + + CommandAPIPaperConfig shouldHookPaperReload(boolean hooked); // Whether the CommandAPI should hook into the Paper-exclusive ServerResourcesReloadedEvent +} +``` -For example, to load the CommandAPI on Bukkit with all logging disabled, you can use the following: +```java,Spigot +public class CommandAPISpigotConfig extends CommandAPIBukkitConfig { + CommandAPISpigotConfig(JavaPlugin plugin); +} +``` + +
+ +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 registers 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 a Bukkit-based server with all logging disabled, you can use the following:
-```java,Java -{{#include ../../commandapi-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java:setupShading1}} +```java,Java_(Paper) +{{#include ../../commandapi-platforms/commandapi-paper/commandapi-paper-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java:setupShading1}} +``` + +```java,Java_(Spigot) +{{#include ../../commandapi-platforms/commandapi-spigot/commandapi-spigot-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java:setupShading1}} +``` + +```kotlin,Kotlin_(Paper) +{{#include ../../commandapi-platforms/commandapi-paper/commandapi-paper-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt:setupShading1}} ``` -```kotlin,Kotlin -{{#include ../../commandapi-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt:setupShading1}} +```kotlin,Kotlin_(Spigot) +{{#include ../../commandapi-platforms/commandapi-spigot/commandapi-spigot-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt:setupShading1}} ```
@@ -84,12 +107,20 @@ The `onDisable()` method disables the CommandAPI gracefully. This should be plac
-```java,Java -public {{#include ../../commandapi-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java:setupShading2}} +```java,Java_(Paper) +public {{#include ../../commandapi-platforms/commandapi-paper/commandapi-paper-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java:setupShading2}} ``` -```kotlin,Kotlin -{{#include ../../commandapi-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt:setupShading2}} +```java,Java_(Spigot) +public {{#include ../../commandapi-platforms/commandapi-spigot/commandapi-spigot-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java:setupShading2}} +``` + +```kotlin,Kotlin_(Paper) +{{#include ../../commandapi-platforms/commandapi-paper/commandapi-paper-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt:setupShading2}} +``` + +```kotlin,Kotlin_(Spigot) +{{#include ../../commandapi-platforms/commandapi-spigot/commandapi-spigot-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt:setupShading2}} ```
@@ -110,27 +141,48 @@ By default, the CommandAPI is written in the `dev.jorel.commandapi` package. It ## Shading with Maven -To shade the CommandAPI into a maven project, you'll need to use the `commandapi-bukkit-shade` dependency, which is optimized for shading and doesn't include plugin-specific files _(such as `plugin.yml`)_. Here you have a choice between the Spigot-mapped version and the Mojang-mapped version. **You do not need to use `commandapi-bukkit-core` if you are shading**: +When shading the CommandAPI, you have the option to choose between our version for Paper and our version for Spigot. The respective artifacts are the `commandapi-paper-shade` and the `commandapi-spigot-shade` modules. These are optimized for shading and don't include plugin specific files _(such as `plugin.yml`)_. +You also can choose between a Mojang-mapped and a Spigot-mapped version: Add the CommandAPI shade dependency:
-```xml,Spigot_Mappings +```xml,Paper_(Spigot_Mappings) dev.jorel - commandapi-bukkit-shade + commandapi-paper-shade 9.6.0-SNAPSHOT ``` -```xml,Mojang_Mappings +```xml,Paper_(Mojang_Mappings) dev.jorel - commandapi-bukkit-shade-mojang-mapped + commandapi-paper-shade-mojang-mapped + 9.6.0-SNAPSHOT + + +``` + +```xml,Spigot_(Spigot_Mappings) + + + dev.jorel + commandapi-spigot-shade + 9.6.0-SNAPSHOT + + +``` + +```xml,Spigot_(Mojang_Mappings) + + + dev.jorel + commandapi-spigot-shade-mojang-mapped 9.6.0-SNAPSHOT @@ -225,27 +277,51 @@ Next, we declare our dependencies:
-```groovy,build.gradle_(Spigot_Mappings) +```groovy,build.gradle_(Spigot_Mappings_(Paper)) +dependencies { + implementation "dev.jorel:commandapi-paper-shade:9.6.0-SNAPSHOT" +} +``` + +```groovy,build.gradle_(Spigot_Mappings_(Spigot)) +dependencies { + implementation "dev.jorel:commandapi-spigot-shade:9.6.0-SNAPSHOT" +} +``` + +```groovy,build.gradle_(Mojang_Mappings_(Paper)) +dependencies { + implementation "dev.jorel:commandapi-paper-shade-mojang-mapped:9.6.0-SNAPSHOT" +} +``` + +```groovy,build.gradle_(Mojang_Mappings_(Spigot)) dependencies { - implementation "dev.jorel:commandapi-bukkit-shade:9.6.0-SNAPSHOT" + implementation "dev.jorel:commandapi-spigot-shade-mojang-mapped:9.6.0-SNAPSHOT" } ``` -```groovy,build.gradle_(Mojang_Mappings) +```kotlin,build.gradle.kts_(Spigot_Mappings_(Paper)) dependencies { - implementation "dev.jorel:commandapi-bukkit-shade-mojang-mapped:9.6.0-SNAPSHOT" + implementation("dev.jorel:commandapi-paper-shade:9.6.0-SNAPSHOT") } ``` -```kotlin,build.gradle.kts_(Spigot_Mappings) +```kotlin,build.gradle.kts_(Spigot_Mappings_(Spigot)) dependencies { - implementation("dev.jorel:commandapi-bukkit-shade:9.6.0-SNAPSHOT") + implementation("dev.jorel:commandapi-spigot-shade:9.6.0-SNAPSHOT") } ``` -```kotlin,build.gradle.kts_(Mojang_Mappings) +```kotlin,build.gradle.kts_(Mojang_Mappings_(Paper)) dependencies { - implementation("dev.jorel:commandapi-bukkit-shade-mojang-mapped:9.6.0-SNAPSHOT") + implementation("dev.jorel:commandapi-paper-shade-mojang-mapped:9.6.0-SNAPSHOT") +} +``` + +```kotlin,build.gradle.kts_(Mojang_Mappings_(Spigot)) +dependencies { + implementation("dev.jorel:commandapi-spigot-shade-mojang-mapped:9.6.0-SNAPSHOT") } ``` @@ -255,10 +331,21 @@ Then we add it to the `shadowJar` task configuration and relocate the CommandAPI
-```groovy,build.gradle_(Spigot_Mappings) +```groovy,build.gradle_(Spigot_Mappings_(Paper)) +shadowJar { + dependencies { + include dependency("dev.jorel:commandapi-paper-shade:9.6.0-SNAPSHOT") + } + + // TODO: Change this to my own package name + relocate("dev.jorel.commandapi", "my.custom.package.commandapi") +} +``` + +```groovy,build.gradle_(Spigot_Mappings_(Spigot)) shadowJar { dependencies { - include dependency("dev.jorel:commandapi-bukkit-shade:9.6.0-SNAPSHOT") + include dependency("dev.jorel:commandapi-spigot-shade:9.6.0-SNAPSHOT") } // TODO: Change this to my own package name @@ -266,10 +353,43 @@ shadowJar { } ``` -```groovy,build.gradle_(Mojang_Mappings) +```groovy,build.gradle_(Mojang_Mappings_(Paper)) shadowJar { dependencies { - include dependency("dev.jorel:commandapi-bukkit-shade-mojang-mapped:9.6.0-SNAPSHOT") + include dependency("dev.jorel:commandapi-paper-shade-mojang-mapped:9.6.0-SNAPSHOT") + } + + // TODO: Change this to my own package name + relocate("dev.jorel.commandapi", "my.custom.package.commandapi") +} +``` + +```groovy,build.gradle_(Mojang_Mappings_(Spigot)) +shadowJar { + dependencies { + include dependency("dev.jorel:commandapi-spigot-shade-mojang-mapped:9.6.0-SNAPSHOT") + } + + // TODO: Change this to my own package name + relocate("dev.jorel.commandapi", "my.custom.package.commandapi") +} +``` + +```kotlin,build.gradle.kts_(Spigot_Mappings_(Paper)) +tasks.withType { + dependencies { + include(dependency("dev.jorel:commandapi-paper-shade:9.6.0-SNAPSHOT")) + } + + // TODO: Change this to my own package name + relocate("dev.jorel.commandapi", "my.custom.package.commandapi") +} +``` + +```kotlin,build.gradle.kts_(Spigot_Mappings_(Spigot)) +tasks.withType { + dependencies { + include(dependency("dev.jorel:commandapi-spigot-shade:9.6.0-SNAPSHOT")) } // TODO: Change this to my own package name @@ -277,10 +397,10 @@ shadowJar { } ``` -```kotlin,build.gradle.kts_(Spigot_Mappings) +```kotlin,build.gradle.kts_(Mojang_Mappings_(Paper)) tasks.withType { dependencies { - include(dependency("dev.jorel:commandapi-bukkit-shade:9.6.0-SNAPSHOT")) + include(dependency("dev.jorel:commandapi-paper-shade-mojang-mapped:9.6.0-SNAPSHOT")) } // TODO: Change this to my own package name @@ -288,10 +408,10 @@ tasks.withType { } ``` -```kotlin,build.gradle.kts_(Mojang_Mappings) +```kotlin,build.gradle.kts_(Mojang_Mappings_(Spigot)) tasks.withType { dependencies { - include(dependency("dev.jorel:commandapi-bukkit-shade-mojang-mapped:9.6.0-SNAPSHOT")) + include(dependency("dev.jorel:commandapi-spigot-shade-mojang-mapped:9.6.0-SNAPSHOT")) } // TODO: Change this to my own package name diff --git a/update.sh b/update.sh index 5cd0b59f6b..06fe8d04c2 100755 --- a/update.sh +++ b/update.sh @@ -15,9 +15,12 @@ sed -i "s/$oldVer<\/version>/$newVer<\/version>/" docssrc/src/ sed -i "s/$oldVer<\/version>/$newVer<\/version>/" docssrc/src/kotlinintro.md # Gradle -sed -i "s/dev\.jorel:commandapi-bukkit-shade:$oldVer/dev\.jorel:commandapi-bukkit-shade:$newVer/" docssrc/src/setup_shading.md -sed -i "s/dev\.jorel:commandapi-bukkit-shade-mojang-mapped:$oldVer/dev\.jorel:commandapi-bukkit-shade-mojang-mapped:$newVer/" docssrc/src/setup_shading.md -sed -i "s/dev\.jorel:commandapi-bukkit-core:$oldVer/dev\.jorel:commandapi-bukkit-core:$newVer/" docssrc/src/setup_dev.md +sed -i "s/dev\.jorel:commandapi-paper-shade:$oldVer/dev\.jorel:commandapi-paper-shade:$newVer/" docssrc/src/setup_shading.md +sed -i "s/dev\.jorel:commandapi-spigot-shade:$oldVer/dev\.jorel:commandapi-spigot-shade:$newVer/" docssrc/src/setup_shading.md +sed -i "s/dev\.jorel:commandapi-paper-shade-mojang-mapped:$oldVer/dev\.jorel:commandapi-paper-shade-mojang-mapped:$newVer/" docssrc/src/setup_shading.md +sed -i "s/dev\.jorel:commandapi-spigot-shade-mojang-mapped:$oldVer/dev\.jorel:commandapi-spigot-shade-mojang-mapped:$newVer/" docssrc/src/setup_shading.md +sed -i "s/dev\.jorel:commandapi-paper-core:$oldVer/dev\.jorel:commandapi-paper-core:$newVer/" docssrc/src/setup_dev.md +sed -i "s/dev\.jorel:commandapi-spigot-core:$oldVer/dev\.jorel:commandapi-spigot-core:$newVer/" docssrc/src/setup_dev.md sed -i "s/dev\.jorel:commandapi-annotations:$oldVer/dev\.jorel:commandapi-annotations:$newVer/" docssrc/src/setup_annotations.md sed -i "s/dev\.jorel:commandapi-kotlin-bukkit:$oldVer/dev\.jorel:commandapi-kotlin-bukkit:$newVer/" docssrc/src/kotlinintro.md sed -i "s/dev\.jorel:commandapi-kotlin-velocity:$oldVer/dev\.jorel:commandapi-kotlin-velocity:$newVer/" docssrc/src/kotlinintro.md