Class LegacyPaperCommandManager<C>
- Type Parameters:
C- command sender type
- All Implemented Interfaces:
BrigadierManagerHolder<C,,Object> PluginHolder,CommandBuilderSource<C>,SenderMapperHolder<CommandSender,,C> Stateful<RegistrationState>
CommandManager implementation for Bukkit-based platforms (i.e. Spigot, Paper),
with specific support for Paper features (gated behind CloudBukkitCapabilities for
"backwards-compatibility").
This command manager uses legacy Bukkit command APIs. It's recommended to use
the PaperCommandManager instead when supporting Paper 1.20.6+ exclusively.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.incendo.cloud.bukkit.BukkitCommandManager
BukkitCommandManager.BrigadierInitializationException, BukkitCommandManager.InitializationExceptionNested classes/interfaces inherited from interface org.incendo.cloud.brigadier.BrigadierManagerHolder
BrigadierManagerHolder.BrigadierManagerNotPresent -
Constructor Summary
ConstructorsConstructorDescriptionLegacyPaperCommandManager(@NonNull Plugin owningPlugin, @NonNull ExecutionCoordinator<C> commandExecutionCoordinator, @NonNull SenderMapper<CommandSender, C> senderMapper) Create a new Paper command manager. -
Method Summary
Modifier and TypeMethodDescriptioncreateNative(@NonNull Plugin owningPlugin, @NonNull ExecutionCoordinator<CommandSender> commandExecutionCoordinator) Create a command manager using Bukkit'sCommandSenderas the sender type.booleanvoidRegisters asynchronous completions using the Paper API.voidAttempts to enable Brigadier command registration through the Paper API, falling back toBukkitCommandManager.registerBrigadier()if that fails.voidDeprecated.This method will continue to work while the Paper commands API is still incubating, but will eventually no longer function when the old API is removed.Methods inherited from class org.incendo.cloud.bukkit.BukkitCommandManager
checkBrigadierCompatibility, hasPermission, owningPlugin, senderMapper, splitAliases, splitAliasesMethods inherited from class org.incendo.cloud.CommandManager
appendSuggestionMapper, capabilities, captionFormatter, captionFormatter, captionRegistry, captionRegistry, command, command, command, commandExecutor, commandRegistrationHandler, commandRegistrationHandler, commands, commandSyntaxFormatter, commandSyntaxFormatter, commandTree, componentBuilder, createDefaultCommandMeta, createHelpHandler, createHelpHandler, decorateBuilder, deleteRootCommand, exceptionController, flagBuilder, hasCapability, helpHandlerFactory, helpHandlerFactory, isCommandRegistrationAllowed, lockRegistration, parameterInjectorRegistry, parserRegistry, postprocessContext, preprocessContext, registerCapability, registerCommandPostProcessor, registerCommandPreProcessor, registerDefaultExceptionHandlers, rootCommands, settings, state, suggestionFactory, suggestionMapper, suggestionMapper, suggestionProcessor, suggestionProcessor, testPermission, transitionIfPossibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.incendo.cloud.CommandBuilderSource
commandBuilder, commandBuilder, commandBuilder, commandBuilder, commandBuilder, commandBuilderMethods inherited from interface org.incendo.cloud.state.Stateful
requireState, transitionOrThrow
-
Constructor Details
-
LegacyPaperCommandManager
@API(status=STABLE, since="2.0.0") public LegacyPaperCommandManager(@NonNull Plugin owningPlugin, @NonNull ExecutionCoordinator<C> commandExecutionCoordinator, @NonNull SenderMapper<CommandSender, C> senderMapper) throws BukkitCommandManager.InitializationExceptionCreate a new Paper command manager.- Parameters:
owningPlugin- Plugin constructing the manager. Used when registering commands to the command map, registering event listeners, etc.commandExecutionCoordinator- Execution coordinator instance. Due to Bukkit blocking the main thread for suggestion requests, it's potentially unsafe to use anything other thanExecutionCoordinator.nonSchedulingExecutor()forExecutionCoordinator.Builder.suggestionsExecutor(Executor). Once the coordinator, a suggestion provider, parser, or similar routes suggestion logic off of the calling (main) thread, it won't be possible to schedule further logic back to the main thread without a deadlock. When Brigadier support is active, this issue is avoided, as it allows for non-blocking suggestions. Paper's asynchronous completion API can also be used to avoid this issue:registerAsynchronousCompletions()senderMapper- Mapper between Bukkit'sCommandSenderand the command sender typeC.- Throws:
BukkitCommandManager.InitializationException- if construction of the manager fails- See Also:
-
-
Method Details
-
createNative
@API(status=STABLE, since="2.0.0") public static @NonNull LegacyPaperCommandManager<@NonNull CommandSender> createNative(@NonNull Plugin owningPlugin, @NonNull ExecutionCoordinator<CommandSender> commandExecutionCoordinator) throws BukkitCommandManager.InitializationException Create a command manager using Bukkit'sCommandSenderas the sender type.- Parameters:
owningPlugin- plugin owning the command managercommandExecutionCoordinator- execution coordinator instance- Returns:
- a new command manager
- Throws:
BukkitCommandManager.InitializationException- if the construction of the manager fails- Since:
- 1.5.0
- See Also:
-
registerBrigadier
Attempts to enable Brigadier command registration through the Paper API, falling back toBukkitCommandManager.registerBrigadier()if that fails.Callers should check for
CloudBukkitCapabilities.NATIVE_BRIGADIERfirst to avoid exceptions.A check for
CloudBukkitCapabilities.NATIVE_BRIGADIER||CloudBukkitCapabilities.COMMODORE_BRIGADIERmay also be appropriate for some use cases (because of the fallback behavior), but not most, as Commodore does not offer any functionality on modern versions (see the documentation forCloudBukkitCapabilities.COMMODORE_BRIGADIER).- Overrides:
registerBrigadierin classBukkitCommandManager<C>- Throws:
BukkitCommandManager.BrigadierInitializationException- when the prerequisite capabilities are not present or some other issue occurs during registration of Brigadier support- See Also:
-
registerLegacyPaperBrigadier
@Deprecated public void registerLegacyPaperBrigadier() throws BukkitCommandManager.BrigadierInitializationExceptionDeprecated.This method will continue to work while the Paper commands API is still incubating, but will eventually no longer function when the old API is removed.Variant ofregisterBrigadier()that only uses the old Paper-MojangAPI, even when the modern Paper commands API is present. This may be useful for debugging issues with the new Paper command system.- Throws:
BukkitCommandManager.BrigadierInitializationException- when the prerequisite capabilities are not present or some other issue occurs during registration of Brigadier support
-
hasBrigadierManager
- Specified by:
hasBrigadierManagerin interfaceBrigadierManagerHolder<C,Object> - Overrides:
hasBrigadierManagerin classBukkitCommandManager<C>- Returns:
- Since:
- 2.0.0
-
brigadierManager
- Specified by:
brigadierManagerin interfaceBrigadierManagerHolder<C,Object> - Overrides:
brigadierManagerin classBukkitCommandManager<C>- Returns:
- Throws:
BrigadierManagerHolder.BrigadierManagerNotPresent- whenhasBrigadierManager()is false- Since:
- 1.2.0
-
registerAsynchronousCompletions
Registers asynchronous completions using the Paper API. This means the calling thread for suggestion queries will be a thread other than themain server thread(or, the sender's thread context on Folia).Requires the
CloudBukkitCapabilities.ASYNCHRONOUS_COMPLETIONcapability to be present.It's not recommended to use this in combination with
registerBrigadier(), as Brigadier allows for non-blocking suggestions and the async completion API reduces the fidelity of suggestions compared to using Brigadier directly (seeLegacyPaperCommandManager(Plugin, ExecutionCoordinator, SenderMapper)).- Throws:
IllegalStateException- when the server does not support asynchronous completions- See Also:
-