Skip to content

Commit 9a298d0

Browse files
committed
Fix #388
1 parent 3d65f11 commit 9a298d0

4 files changed

Lines changed: 15 additions & 4 deletions

File tree

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ protected final void setSplitAliases(final boolean value) {
273273
}
274274

275275
/**
276-
* Check whether or not Brigadier can be used on the server instance
276+
* Check whether Brigadier can be used on the server instance
277277
*
278278
* @throws BrigadierFailureException An exception is thrown if Brigadier isn't available. The exception
279279
* will contain the reason for this.
@@ -320,6 +320,9 @@ public final boolean queryCapability(final @NonNull CloudBukkitCapabilities capa
320320
public void registerBrigadier() throws BrigadierFailureException {
321321
this.requireState(RegistrationState.BEFORE_REGISTRATION);
322322
this.checkBrigadierCompatibility();
323+
if (!this.hasCapability(CloudBukkitCapabilities.COMMODORE_BRIGADIER)) {
324+
throw new BrigadierFailureException(BrigadierFailureReason.VERSION_TOO_HIGH);
325+
}
323326
try {
324327
final CloudCommodoreManager<C> cloudCommodoreManager = new CloudCommodoreManager<>(this);
325328
cloudCommodoreManager.initialize(this);
@@ -408,6 +411,7 @@ final void lockIfBrigadierCapable() {
408411
public enum BrigadierFailureReason {
409412
COMMODORE_NOT_PRESENT,
410413
VERSION_TOO_LOW,
414+
VERSION_TOO_HIGH,
411415
PAPER_BRIGADIER_INITIALIZATION_FAILURE
412416
}
413417

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ public enum CloudBukkitCapabilities implements CloudCapability {
4040
NATIVE_BRIGADIER(CraftBukkitReflection.classExists(
4141
"com.destroystokyo.paper.event.brigadier.CommandRegisteredEvent")),
4242

43-
COMMODORE_BRIGADIER(BRIGADIER.capable() && !NATIVE_BRIGADIER.capable()),
43+
COMMODORE_BRIGADIER(BRIGADIER.capable()
44+
&& !NATIVE_BRIGADIER.capable()
45+
&& !CraftBukkitReflection.classExists("org.bukkit.entity.Warden")),
4446

4547
ASYNCHRONOUS_COMPLETION(CraftBukkitReflection.classExists(
4648
"com.destroystokyo.paper.event.server.AsyncTabCompleteEvent"));

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,12 @@ private void unregisterWithCommodore(
127127
try {
128128
final Class<?> commodoreImpl = this.commodore.getClass();
129129

130-
final Method removeChild = commodoreImpl.getDeclaredMethod("removeChild", RootCommandNode.class, String.class);
130+
Method removeChild;
131+
try {
132+
removeChild = commodoreImpl.getDeclaredMethod("removeChild", RootCommandNode.class, String.class);
133+
} catch (final NoSuchMethodException ex) {
134+
removeChild = commodoreImpl.getSuperclass().getDeclaredMethod("removeChild", RootCommandNode.class, String.class);
135+
}
131136
removeChild.setAccessible(true);
132137

133138
removeChild.invoke(

gradle/libs.versions.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ versions:
3535
guava: 21.0-jre
3636
brigadier: 1.0.17
3737
bukkit: 1.13.2-R0.1-SNAPSHOT
38-
commodore: 2.0
38+
commodore: 2.2
3939
bungeecord: 1.8-SNAPSHOT
4040
cloudburst: 1.0.0-SNAPSHOT
4141
adventureApi: 4.9.3

0 commit comments

Comments
 (0)