Skip to content

Commit

Permalink
Fix #388
Browse files Browse the repository at this point in the history
  • Loading branch information
jpenilla committed Aug 19, 2022
1 parent 3d65f11 commit 9a298d0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ protected final void setSplitAliases(final boolean value) {
}

/**
* Check whether or not Brigadier can be used on the server instance
* Check whether Brigadier can be used on the server instance
*
* @throws BrigadierFailureException An exception is thrown if Brigadier isn't available. The exception
* will contain the reason for this.
Expand Down Expand Up @@ -320,6 +320,9 @@ public final boolean queryCapability(final @NonNull CloudBukkitCapabilities capa
public void registerBrigadier() throws BrigadierFailureException {
this.requireState(RegistrationState.BEFORE_REGISTRATION);
this.checkBrigadierCompatibility();
if (!this.hasCapability(CloudBukkitCapabilities.COMMODORE_BRIGADIER)) {
throw new BrigadierFailureException(BrigadierFailureReason.VERSION_TOO_HIGH);
}
try {
final CloudCommodoreManager<C> cloudCommodoreManager = new CloudCommodoreManager<>(this);
cloudCommodoreManager.initialize(this);
Expand Down Expand Up @@ -408,6 +411,7 @@ final void lockIfBrigadierCapable() {
public enum BrigadierFailureReason {
COMMODORE_NOT_PRESENT,
VERSION_TOO_LOW,
VERSION_TOO_HIGH,
PAPER_BRIGADIER_INITIALIZATION_FAILURE
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ public enum CloudBukkitCapabilities implements CloudCapability {
NATIVE_BRIGADIER(CraftBukkitReflection.classExists(
"com.destroystokyo.paper.event.brigadier.CommandRegisteredEvent")),

COMMODORE_BRIGADIER(BRIGADIER.capable() && !NATIVE_BRIGADIER.capable()),
COMMODORE_BRIGADIER(BRIGADIER.capable()
&& !NATIVE_BRIGADIER.capable()
&& !CraftBukkitReflection.classExists("org.bukkit.entity.Warden")),

ASYNCHRONOUS_COMPLETION(CraftBukkitReflection.classExists(
"com.destroystokyo.paper.event.server.AsyncTabCompleteEvent"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,12 @@ private void unregisterWithCommodore(
try {
final Class<?> commodoreImpl = this.commodore.getClass();

final Method removeChild = commodoreImpl.getDeclaredMethod("removeChild", RootCommandNode.class, String.class);
Method removeChild;
try {
removeChild = commodoreImpl.getDeclaredMethod("removeChild", RootCommandNode.class, String.class);
} catch (final NoSuchMethodException ex) {
removeChild = commodoreImpl.getSuperclass().getDeclaredMethod("removeChild", RootCommandNode.class, String.class);
}
removeChild.setAccessible(true);

removeChild.invoke(
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ versions:
guava: 21.0-jre
brigadier: 1.0.17
bukkit: 1.13.2-R0.1-SNAPSHOT
commodore: 2.0
commodore: 2.2
bungeecord: 1.8-SNAPSHOT
cloudburst: 1.0.0-SNAPSHOT
adventureApi: 4.9.3
Expand Down

0 comments on commit 9a298d0

Please sign in to comment.