Package cloud.commandframework.pircbotx
Class PircBotXCommandManager<C>
- java.lang.Object
-
- cloud.commandframework.CommandManager<C>
-
- cloud.commandframework.pircbotx.PircBotXCommandManager<C>
-
- Type Parameters:
C
- Command sender type
public class PircBotXCommandManager<C> extends cloud.commandframework.CommandManager<C>
Command manager implementation for PircBotX 2.0- Since:
- 1.1.0
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ARGUMENT_PARSE_FAILURE_USER
Default caption forARGUMENT_PARSE_FAILURE_USER_KEY
static cloud.commandframework.captions.Caption
ARGUMENT_PARSE_FAILURE_USER_KEY
Variables: {input}static java.lang.String
PIRCBOTX_META_KEY
Meta key for accessing thePircBotX
instance from aCommandContext
instance
-
Constructor Summary
Constructors Constructor Description PircBotXCommandManager(@NonNull org.pircbotx.PircBotX pircBotX, @NonNull java.util.function.Function<@NonNull cloud.commandframework.CommandTree<C>,@NonNull cloud.commandframework.execution.CommandExecutionCoordinator<C>> commandExecutionCoordinator, @NonNull cloud.commandframework.internal.CommandRegistrationHandler commandRegistrationHandler, @NonNull java.util.function.BiFunction<C,java.lang.String,java.lang.Boolean> permissionFunction, @NonNull java.util.function.Function<org.pircbotx.User,C> userMapper, @NonNull java.lang.String commandPrefix)
Create a new command manager instance
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @NonNull cloud.commandframework.meta.CommandMeta
createDefaultCommandMeta()
@NonNull java.lang.String
getCommandPrefix()
Get the command prefix.boolean
hasPermission(@NonNull C sender, @NonNull java.lang.String permission)
-
Methods inherited from class cloud.commandframework.CommandManager
argumentBuilder, command, command, commandBuilder, commandBuilder, commandBuilder, commandBuilder, commandBuilder, commandBuilder, commandBuilder, commandBuilder, commandBuilder, executeCommand, flagBuilder, getCaptionRegistry, getCommandHelpHandler, getCommandHelpHandler, getCommandRegistrationHandler, getCommands, getCommandSuggestionProcessor, getCommandSyntaxFormatter, getCommandTree, getExceptionHandler, getParserRegistry, getRegistrationState, getSetting, handleException, hasPermission, isCommandRegistrationAllowed, lockRegistration, parameterInjectorRegistry, postprocessContext, preprocessContext, registerCommandPostProcessor, registerCommandPreProcessor, registerDefaultCaptions, registerExceptionHandler, requireState, setCaptionRegistry, setCommandRegistrationHandler, setCommandSuggestionProcessor, setCommandSyntaxFormatter, setSetting, suggest, transitionIfPossible, transitionOrThrow
-
-
-
-
Field Detail
-
PIRCBOTX_META_KEY
public static final java.lang.String PIRCBOTX_META_KEY
Meta key for accessing thePircBotX
instance from aCommandContext
instance- See Also:
- Constant Field Values
-
ARGUMENT_PARSE_FAILURE_USER_KEY
public static final cloud.commandframework.captions.Caption ARGUMENT_PARSE_FAILURE_USER_KEY
Variables: {input}
-
ARGUMENT_PARSE_FAILURE_USER
public static final java.lang.String ARGUMENT_PARSE_FAILURE_USER
Default caption forARGUMENT_PARSE_FAILURE_USER_KEY
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PircBotXCommandManager
public PircBotXCommandManager(@NonNull org.pircbotx.PircBotX pircBotX, @NonNull java.util.function.Function<@NonNull cloud.commandframework.CommandTree<C>,@NonNull cloud.commandframework.execution.CommandExecutionCoordinator<C>> commandExecutionCoordinator, @NonNull cloud.commandframework.internal.CommandRegistrationHandler commandRegistrationHandler, @NonNull java.util.function.BiFunction<C,java.lang.String,java.lang.Boolean> permissionFunction, @NonNull java.util.function.Function<org.pircbotx.User,C> userMapper, @NonNull java.lang.String commandPrefix)
Create a new command manager instance- Parameters:
pircBotX
- PircBotX instance. This is used to register theListenerAdapter
that will forward commands to the command dispatchercommandExecutionCoordinator
- Execution coordinator instance. The coordinator is in charge of executing incoming commands. Some considerations must be made when picking a suitable execution coordinator for your platform. For example, an entirely asynchronous coordinator is not suitable when the parsers used in that particular platform are not thread safe. If you have commands that perform blocking operations, however, it might not be a good idea to use a synchronous execution coordinator. In most cases you will want to pick betweenCommandExecutionCoordinator.simpleCoordinator()
andAsynchronousCommandExecutionCoordinator
commandRegistrationHandler
- Command registration handler. This will get called every time a new command is registered to the command manager. This may be used to forward command registrationpermissionFunction
- Function used to determine whether or not a sender is permitted to use a certain command. The first input is the sender of the command, and the second parameter is the the command permission string. The return value should betrue
if the sender is permitted to use the command, elsefalse
userMapper
- Function that mapsusers
to the custom command sender typecommandPrefix
- The prefix that must be applied to all commands for the command to be valid
-
-
Method Detail
-
hasPermission
public final boolean hasPermission(@NonNull C sender, @NonNull java.lang.String permission)
- Specified by:
hasPermission
in classcloud.commandframework.CommandManager<C>
-
createDefaultCommandMeta
public final @NonNull cloud.commandframework.meta.CommandMeta createDefaultCommandMeta()
- Specified by:
createDefaultCommandMeta
in classcloud.commandframework.CommandManager<C>
-
getCommandPrefix
public final @NonNull java.lang.String getCommandPrefix()
Get the command prefix. A message should be classed as a command if, and only if, it is prefixed with this prefix- Returns:
- Command prefix
-
-