Skip to content

Commit 5bd2b90

Browse files
committed
Improve docs around Brigadier on bukkit/paper
1 parent c8f0703 commit 5bd2b90

5 files changed

Lines changed: 35 additions & 7 deletions

File tree

cloud-minecraft/cloud-bukkit/src/main/java/cloud/commandframework/bukkit/BukkitCommandManager.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,10 @@ public final boolean queryCapability(final @NonNull CloudBukkitCapabilities capa
331331
}
332332

333333
/**
334-
* Attempt to register the Brigadier mapper, and return it.
334+
* Attempts to enable Brigadier command registration through Commodore.
335+
*
336+
* <p>Callers should check for {@link CloudBukkitCapabilities#COMMODORE_BRIGADIER} first
337+
* to avoid exceptions.</p>
335338
*
336339
* @throws BrigadierFailureException If Brigadier isn't
337340
* supported by the platform

cloud-minecraft/cloud-bukkit/src/main/java/cloud/commandframework/bukkit/CloudBukkitCapabilities.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,36 @@
3434
* Capabilities for the Bukkit module
3535
*/
3636
public enum CloudBukkitCapabilities implements CloudCapability {
37+
/**
38+
* Whether Brigadier is present in the current environment. Certain parser types require this, and are able to work
39+
* even if a capability for Brigadier command registration is not present (as long as this capability is present).
40+
*/
3741
BRIGADIER(CraftBukkitReflection.classExists("com.mojang.brigadier.tree.CommandNode")
3842
&& CraftBukkitReflection.findOBCClass("command.BukkitCommandWrapper") != null),
3943

44+
/**
45+
* Whether support for native Brigadier command registration is available
46+
* through the Paper API ({@code PaperCommandManager#registerBrigadier} from {@code cloud-paper}).
47+
*/
4048
NATIVE_BRIGADIER(CraftBukkitReflection.classExists(
4149
"com.destroystokyo.paper.event.brigadier.CommandRegisteredEvent")),
4250

51+
/**
52+
* Whether support for Brigadier command registration is available through Commodore
53+
* ({@link BukkitCommandManager#registerBrigadier}).
54+
*
55+
* <p><b>Note:</b> As of 1.19.2, Commodore simply delegates to the same Paper API as cloud is capable of using directly,
56+
* doing nothing on non-Paper Bukkit implementations. As such, this capability will not be present in 1.19.2+ environments.
57+
* Users should prefer using {@code PaperCommandManager} from {@code cloud-paper} and checking for
58+
* {@link #NATIVE_BRIGADIER}.</p>
59+
*/
4360
COMMODORE_BRIGADIER(BRIGADIER.capable()
4461
&& !NATIVE_BRIGADIER.capable()
4562
&& !CraftBukkitReflection.classExists("org.bukkit.entity.Warden")),
4663

64+
/**
65+
* Whether asynchronous command completions are supported through the Paper API.
66+
*/
4767
ASYNCHRONOUS_COMPLETION(CraftBukkitReflection.classExists(
4868
"com.destroystokyo.paper.event.server.AsyncTabCompleteEvent"));
4969

cloud-minecraft/cloud-paper/src/main/java/cloud/commandframework/paper/PaperCommandManager.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,16 @@ public PaperCommandManager(
113113
}
114114

115115
/**
116-
* Register Brigadier mappings using the native paper events
116+
* Attempts to enable Brigadier command registration through the Paper API, falling
117+
* back to {@link BukkitCommandManager#registerBrigadier()} if that fails.
118+
*
119+
* <p>Callers should check for {@link CloudBukkitCapabilities#NATIVE_BRIGADIER} first
120+
* to avoid exceptions.</p>
121+
*
122+
* <p>A check for {@link CloudBukkitCapabilities#NATIVE_BRIGADIER} {@code ||} {@link CloudBukkitCapabilities#COMMODORE_BRIGADIER}
123+
* may also be appropriate for some use cases (because of the fallback behavior), but not most, as Commodore does not offer
124+
* any functionality on modern
125+
* versions (see the documentation for {@link CloudBukkitCapabilities#COMMODORE_BRIGADIER}).</p>
117126
*
118127
* @throws BrigadierFailureException Exception thrown if the mappings cannot be registered
119128
*/

examples/example-bukkit/build.gradle.kts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ dependencies {
1212
implementation(project(":cloud-annotations"))
1313
implementation(project(":cloud-minecraft-extras"))
1414
/* Extras */
15-
implementation(libs.commodore) {
16-
isTransitive = false
17-
}
1815
implementation(libs.adventurePlatformBukkit)
1916
/* Bukkit */
2017
compileOnly(libs.bukkit)
@@ -25,7 +22,6 @@ dependencies {
2522
tasks {
2623
shadowJar {
2724
relocate("net.kyori", "cloud.commandframework.example.kyori")
28-
relocate("me.lucko", "cloud.commandframework.example.lucko")
2925
relocate("io.leangen.geantyref", "cloud.commandframework.example.geantyref")
3026
}
3127
assemble {

examples/example-bukkit/src/main/java/cloud/commandframework/examples/bukkit/ExamplePlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public void onEnable() {
174174
//
175175
// Register Brigadier mappings
176176
//
177-
if (this.manager.hasCapability(CloudBukkitCapabilities.BRIGADIER)) {
177+
if (this.manager.hasCapability(CloudBukkitCapabilities.NATIVE_BRIGADIER)) {
178178
this.manager.registerBrigadier();
179179
}
180180
//

0 commit comments

Comments
 (0)