Move some CommandDispatcher methods

This commit is contained in:
themode 2021-02-13 00:34:25 +01:00
parent 367889a374
commit 1d64cafcf2

View File

@ -55,6 +55,23 @@ public class CommandDispatcher {
this.commands.remove(command);
}
@NotNull
public Set<Command> getCommands() {
return Collections.unmodifiableSet(commands);
}
/**
* Gets the command class associated with the name.
*
* @param commandName the command name
* @return the {@link Command} associated with the name, null if not any
*/
@Nullable
public Command findCommand(@NotNull String commandName) {
commandName = commandName.toLowerCase();
return commandMap.getOrDefault(commandName, null);
}
/**
* Checks if the command exists, and execute it.
*
@ -114,23 +131,6 @@ public class CommandDispatcher {
return result;
}
@NotNull
public Set<Command> getCommands() {
return Collections.unmodifiableSet(commands);
}
/**
* Gets the command class associated with the name.
*
* @param commandName the command name
* @return the {@link Command} associated with the name, null if not any
*/
@Nullable
public Command findCommand(@NotNull String commandName) {
commandName = commandName.toLowerCase();
return commandMap.getOrDefault(commandName, null);
}
@Nullable
private ParsedCommand findParsedCommand(@NotNull Command command, @NotNull String[] args) {
ParsedCommand parsedCommand = new ParsedCommand();