Package cn.ycraft.limbo.command
Class CommandHandler
java.lang.Object
cn.ycraft.limbo.command.CommandHandler
- All Implemented Interfaces:
NamedExecutor
,CommandExecutor
,TabCompleter
- Direct Known Subclasses:
AllowlistCommands
,DefaultCommands
public abstract class CommandHandler
extends Object
implements TabCompleter, NamedExecutor, CommandExecutor
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final @NotNull Map<String,
SubCommand<?>> protected final @NotNull Map<String,
CommandHandler> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
execute
(@NotNull CommandSender sender, String[] args) protected @Nullable CommandHandler
getHandler
(@NotNull String name) protected @Nullable SubCommand<?>
getSubCommand
(@NotNull String name) abstract Void
noArgs
(CommandSender sender) abstract Void
noPermission
(CommandSender sender) onException
(CommandSender sender, String cmd, Exception ex) void
registerHandler
(@NotNull CommandHandler handler, @NotNull String name, @NotNull String... aliases) void
registerSubCommand
(@NotNull SubCommand<?> command, @NotNull String name, @NotNull String... aliases) protected static String[]
shortenArgs
(String[] args) protected static boolean
startsWithIgnoreCase
(@NotNull String string, @NotNull String prefix) tabComplete
(@NotNull CommandSender sender, String[] args) unknownCommand
(CommandSender sender, String[] args) void
unregister
(@NotNull String command) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface cn.ycraft.limbo.command.NamedExecutor
hasPermission, sendMessage, sendMessage, sendMessage
-
Field Details
-
registeredCommands
-
registeredHandlers
-
aliasesMap
-
-
Constructor Details
-
CommandHandler
public CommandHandler()
-
-
Method Details
-
noArgs
-
unknownCommand
-
noPermission
-
onException
-
registerSubCommand
public void registerSubCommand(@NotNull @NotNull SubCommand<?> command, @NotNull @NotNull String name, @NotNull @NotNull String... aliases) -
registerHandler
public void registerHandler(@NotNull @NotNull CommandHandler handler, @NotNull @NotNull String name, @NotNull @NotNull String... aliases) -
unregister
-
execute
- Specified by:
execute
in interfaceCommandExecutor
-
tabComplete
- Specified by:
tabComplete
in interfaceTabCompleter
-
getExecutors
-
getHandler
-
getSubCommand
-
shortenArgs
-
startsWithIgnoreCase
protected static boolean startsWithIgnoreCase(@NotNull @NotNull String string, @NotNull @NotNull String prefix) throws IllegalArgumentException, NullPointerException
-