This commit is contained in:
Jason Penilla 2022-08-18 20:07:14 -07:00 committed by Jason
parent 73a0386a85
commit 4179bc4290
4 changed files with 15 additions and 4 deletions

View file

@ -273,7 +273,7 @@ public class BukkitCommandManager<C> extends CommandManager<C> implements Brigad
}
/**
* 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.
@ -320,6 +320,9 @@ public class BukkitCommandManager<C> extends CommandManager<C> implements Brigad
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);
@ -408,6 +411,7 @@ public class BukkitCommandManager<C> extends CommandManager<C> implements Brigad
public enum BrigadierFailureReason {
COMMODORE_NOT_PRESENT,
VERSION_TOO_LOW,
VERSION_TOO_HIGH,
PAPER_BRIGADIER_INITIALIZATION_FAILURE
}

View file

@ -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"));

View file

@ -127,7 +127,12 @@ class CloudCommodoreManager<C> extends BukkitPluginRegistrationHandler<C> {
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(