Package studio.mevera.imperat
Class BaseImperat<S extends CommandSource>
java.lang.Object
studio.mevera.imperat.BaseImperat<S>
- All Implemented Interfaces:
AnnotationInjector<S>,CommandRegistrar<S>,EventListener,EventPublisher,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()Debugs all registered commands and their usages.@NotNull ExecutionResult<S>execute(@NotNull CommandContext<S> context) Dispatches and executes a command usingCommandContextonly@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 usingCommand@NotNull AnnotationParser<S>Fetches the annotation parsergetCommand(String name) Collection<? extends Command<S>>Gets all registered commandsgetSubCommand(String owningCommand, String name) <E extends Event>
voidlisten(@NotNull Class<E> eventType, @NotNull EventListenerConsumer<E> handler, @NotNull Priority priority, @NotNull ExecutionStrategy strategy) <E extends Event>
voidpublishEvent(E event) <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 aArgumentis 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 parservoidregisterSimpleCommand(Command<S> command) Registering a command into the global registry, it will check for ambiguity with other commands and their tree before registering, if an ambiguity is detected it will throw anAmbiguousCommandExceptionbooleanremoveListener(@NotNull UUID subscriptionId) voidsetAnnotationParser(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
registerGlobalExceptionHandlersMethods inherited from interface studio.mevera.imperat.CommandRegistrar
getCommand, registerCommands, registerCommands, registerCommandsMethods inherited from interface studio.mevera.imperat.events.EventListener
listen, listenMethods inherited from interface studio.mevera.imperat.Imperat
getPlatform, shutdownPlatformMethods inherited from interface studio.mevera.imperat.SourceWrapper
createDummySender, wrapSender
-
Field Details
-
config
-
-
Constructor Details
-
BaseImperat
-
-
Method Details
-
listen
public <E extends Event> void listen(@NotNull @NotNull Class<E> eventType, @NotNull @NotNull EventListenerConsumer<E> handler, @NotNull @NotNull Priority priority, @NotNull @NotNull ExecutionStrategy strategy) - Specified by:
listenin interfaceEventListener
-
publishEvent
- Specified by:
publishEventin interfaceEventPublisher
-
removeListener
- Specified by:
removeListenerin interfaceEventListener
-
config
The config for imperat- Specified by:
configin interfaceImperat<S extends CommandSource>- Returns:
- the config holding all variables.
-
canBeSender
Checks whether the valueType can be a command sender- Specified by:
canBeSenderin interfaceSourceWrapper<S extends CommandSource>- Parameters:
type- the valueType- Returns:
- whether the valueType can be a command sender
-
registerSimpleCommand
Registering a command into the global registry, it will check for ambiguity with other commands and their tree before registering, if an ambiguity is detected it will throw anAmbiguousCommandException- Specified by:
registerSimpleCommandin interfaceCommandRegistrar<S extends CommandSource>- Parameters:
command- the command to register
-
registerCommand
Registers a command class built by the annotations using a parser- Specified by:
registerCommandin interfaceCommandRegistrar<S extends CommandSource>- 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 CommandSource>- Parameters:
commandInstance- the annotated command instance to parse
-
unregisterCommand
Unregisters a command from the internal registry- Specified by:
unregisterCommandin interfaceCommandRegistrar<S extends CommandSource>- 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 CommandSource>
-
getCommand
- Specified by:
getCommandin interfaceCommandRegistrar<S extends CommandSource>- Parameters:
name- the name/alias of the command- Returns:
- fetches
Commandwith specific name/alias
-
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 aArgumentis annotated and checks for the annotations it has.- Specified by:
registerAnnotationsin interfaceAnnotationInjector<S extends CommandSource>- 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 CommandSource>- 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 CommandSource>- Parameters:
owningCommand- the command owning this sub-commandname- the name of the subcommand you're looking for- Returns:
- the subcommand of a command
-
execute
Description copied from interface:ImperatDispatches and executes a command usingCommandContextonly- Specified by:
executein interfaceImperat<S extends CommandSource>- Parameters:
context- the context- Returns:
- the usage match setResult
-
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- Specified by:
executein interfaceImperat<S extends CommandSource>- Parameters:
source- the sender/executor of this commandcommand- the command object to executerawInput- the command's args input- Returns:
- the usage match setResult
-
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- Specified by:
executein interfaceImperat<S extends CommandSource>- Parameters:
source- the sender/executor of this commandcommandName- the name of the command to executerawInput- the command's args input- Returns:
- the usage match setResult
-
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- Specified by:
executein interfaceImperat<S extends CommandSource>- Parameters:
sender- the sender/executor of this commandcommandName- the name of the command to executerawArgsOneLine- the command's args input on ONE LINE- Returns:
- the usage match setResult
-
execute
@NotNull public @NotNull ExecutionResult<S> execute(@NotNull S sender, @NotNull @NotNull String line) Description copied from interface:ImperatDispatches the full command-line- Specified by:
executein interfaceImperat<S extends CommandSource>- Parameters:
sender- the source/sender of the commandline- the command line to dispatch- Returns:
- the usage match setResult
-
autoComplete
public CompletableFuture<List<String>> autoComplete(@NotNull S source, @NotNull @NotNull String fullCommandLine) - Specified by:
autoCompletein interfaceImperat<S extends CommandSource>- 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 CommandSource>- Returns:
- the registered commands
-
getAnnotationParser
Description copied from interface:AnnotationInjectorFetches the annotation parser- Specified by:
getAnnotationParserin interfaceAnnotationInjector<S extends CommandSource>- Returns:
- the annotation parser instance.
- See Also:
-
setAnnotationParser
Changes the instance ofAnnotationParser- Specified by:
setAnnotationParserin interfaceAnnotationInjector<S extends CommandSource>- Parameters:
parser- the parser
-
debug
public void debug()Description copied from interface:ImperatDebugs all registered commands and their usages.- Specified by:
debugin interfaceImperat<S extends CommandSource>
-