Package studio.mevera.imperat
Class BaseImperat<S extends Source>
java.lang.Object
studio.mevera.imperat.BaseImperat<S>
- All Implemented Interfaces:
AnnotationInjector<S>,CommandRegistrar<S>,Imperat<S>,SourceWrapper<S>
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionautoComplete(S source, @NotNull String fullCommandLine) booleancanBeSender(Type type) Checks whether the valueType can be a command sender@NotNull ImperatConfig<S>config()The config for imperatvoiddebug(boolean treeVisualizing) Debugs all registered commands and their usages.@NotNull ExecutionResult<S>Dispatches and executes a command usingContextonly@NotNull ExecutionResult<S>Dispatches the full command-line@NotNull ExecutionResult<S>Dispatches and executes a command with certain raw arguments@NotNull ExecutionResult<S>Dispatches and executes a command with certain raw arguments@NotNull ExecutionResult<S>Dispatches and executes a command with certain raw arguments usingCommandprotected ExecutionResult<S>executeUsage(Command<S> command, S source, Context<S> context, CommandUsage<S> usage, CommandPathSearch<S> dispatch) @NotNull AnnotationParser<S>Fetches the annotation parsergetCommand(String name) Collection<? extends Command<S>>Gets all registered commandsgetSubCommand(String owningCommand, String name) <A extends Annotation>
voidregisterAnnotationReplacer(Class<A> type, AnnotationReplacer<A> replacer) RegistersAnnotationReplacerfinal voidregisterAnnotations(Class<? extends Annotation>... type) Registers a valueType of annotations so that it can be detected byAnnotationReader, it's useful as it allows that valueType of annotation to be recognized as a true Imperat-related annotation to be used in something like checking if aCommandParameteris annotated and checks for the annotations it has.voidregisterCommand(Class<?> commandClass) Registers a command class built by the annotations using a parservoidregisterCommand(Object commandInstance) Registers a command instance built by the annotations using a parservoidregisterCommand(Command<S> command) Registering a command into the dispatchervoidsetAnnotationParser(AnnotationParser<S> parser) Changes the instance ofAnnotationParservoidUnregisters all commands from the internal registryvoidunregisterCommand(String name) Unregisters a command from the internal registryMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface studio.mevera.imperat.AnnotationInjector
registerThrowableHandlerMethods inherited from interface studio.mevera.imperat.CommandRegistrar
getCommand, registerCommands, registerCommands, registerCommandsMethods inherited from interface studio.mevera.imperat.Imperat
getPlatform, shutdownPlatformMethods inherited from interface studio.mevera.imperat.SourceWrapper
wrapSender
-
Field Details
-
config
-
-
Constructor Details
-
BaseImperat
-
-
Method Details
-
config
The config for imperat -
canBeSender
Checks whether the valueType can be a command sender- Specified by:
canBeSenderin interfaceSourceWrapper<S extends Source>- Parameters:
type- the valueType- Returns:
- whether the valueType can be a command sender
-
registerCommand
Registering a command into the dispatcher- Specified by:
registerCommandin interfaceCommandRegistrar<S extends Source>- Parameters:
command- the command to register
-
registerCommand
Registers a command class built by the annotations using a parser- Specified by:
registerCommandin interfaceCommandRegistrar<S extends Source>- Parameters:
commandClass- the annotated command instance to parse
-
registerCommand
Description copied from interface:CommandRegistrarRegisters a command instance built by the annotations using a parser- Specified by:
registerCommandin interfaceCommandRegistrar<S extends Source>- Parameters:
commandInstance- the annotated command instance to parse
-
unregisterCommand
Unregisters a command from the internal registry- Specified by:
unregisterCommandin interfaceCommandRegistrar<S extends Source>- Parameters:
name- the name of the command to unregister
-
unregisterAllCommands
public void unregisterAllCommands()Unregisters all commands from the internal registry- Specified by:
unregisterAllCommandsin interfaceCommandRegistrar<S extends Source>
-
getCommand
- Specified by:
getCommandin interfaceCommandRegistrar<S extends Source>- Parameters:
name- the name/alias of the command- Returns:
- fetches
Commandwith specific name/alias
-
setAnnotationParser
Changes the instance ofAnnotationParser- Specified by:
setAnnotationParserin interfaceAnnotationInjector<S extends Source>- Parameters:
parser- the parser
-
registerAnnotations
Registers a valueType of annotations so that it can be detected byAnnotationReader, it's useful as it allows that valueType of annotation to be recognized as a true Imperat-related annotation to be used in something like checking if aCommandParameteris annotated and checks for the annotations it has.- Specified by:
registerAnnotationsin interfaceAnnotationInjector<S extends Source>- Parameters:
type- the valueType of annotation
-
registerAnnotationReplacer
public <A extends Annotation> void registerAnnotationReplacer(Class<A> type, AnnotationReplacer<A> replacer) RegistersAnnotationReplacer- Specified by:
registerAnnotationReplacerin interfaceAnnotationInjector<S extends Source>- Type Parameters:
A- the valueType of annotation to replace- Parameters:
type- the valueType to replace the annotation byreplacer- the replacer
-
getSubCommand
- Specified by:
getSubCommandin interfaceCommandRegistrar<S extends Source>- Parameters:
owningCommand- the command owning this sub-commandname- the name of the subcommand you're looking for- Returns:
- the subcommand of a command
-
executeUsage
protected ExecutionResult<S> executeUsage(Command<S> command, S source, Context<S> context, CommandUsage<S> usage, CommandPathSearch<S> dispatch) throws ImperatException - Throws:
ImperatException
-
execute
Description copied from interface:ImperatDispatches and executes a command usingContextonly -
execute
@NotNull public @NotNull ExecutionResult<S> execute(@NotNull S source, @NotNull @NotNull Command<S> command, @NotNull @NotNull String commandName, String[] rawInput) Description copied from interface:ImperatDispatches and executes a command with certain raw arguments usingCommand -
execute
@NotNull public @NotNull ExecutionResult<S> execute(@NotNull S source, @NotNull @NotNull String commandName, String[] rawInput) Description copied from interface:ImperatDispatches and executes a command with certain raw arguments -
execute
@NotNull public @NotNull ExecutionResult<S> execute(@NotNull S sender, @NotNull @NotNull String commandName, @NotNull @NotNull String rawArgsOneLine) Description copied from interface:ImperatDispatches and executes a command with certain raw arguments -
execute
@NotNull public @NotNull ExecutionResult<S> execute(@NotNull S sender, @NotNull @NotNull String line) Description copied from interface:ImperatDispatches the full command-line -
autoComplete
public CompletableFuture<List<String>> autoComplete(@NotNull S source, @NotNull @NotNull String fullCommandLine) - Specified by:
autoCompletein interfaceImperat<S extends Source>- Parameters:
source- the sender writing the commandfullCommandLine- the full command line- Returns:
- the suggestions at the current position
-
getRegisteredCommands
Gets all registered commands- Specified by:
getRegisteredCommandsin interfaceCommandRegistrar<S extends Source>- Returns:
- the registered commands
-
getAnnotationParser
Description copied from interface:AnnotationInjectorFetches the annotation parser- Specified by:
getAnnotationParserin interfaceAnnotationInjector<S extends Source>- Returns:
- the annotation parser instance.
- See Also:
-
debug
public void debug(boolean treeVisualizing) Description copied from interface:ImperatDebugs all registered commands and their usages.
-