mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-13 03:26:31 +00:00
added ability to define aliases in the code
This commit is contained in:
@@ -26,7 +26,7 @@ public class CommandManager implements CommandRegistry {
|
||||
public Command findCommandByParameters(String name, UnParsedCommandParameter unParsedCommandParameter) {
|
||||
Optional<Command> commandOptional = commands.stream().filter((Command o )-> {
|
||||
CommandConfiguration commandConfiguration = o.getConfiguration();
|
||||
if(!commandConfiguration.getName().equalsIgnoreCase(name)) {
|
||||
if(!commandNameMatches(name, commandConfiguration)) {
|
||||
return false;
|
||||
}
|
||||
boolean parameterFit;
|
||||
@@ -49,6 +49,18 @@ public class CommandManager implements CommandRegistry {
|
||||
throw new CommandNotFound("Command not found.");
|
||||
}
|
||||
|
||||
private boolean commandNameMatches(String name, CommandConfiguration commandConfiguration) {
|
||||
boolean commandNameMatches = commandConfiguration.getName().equalsIgnoreCase(name);
|
||||
if(commandNameMatches) {
|
||||
return true;
|
||||
}
|
||||
boolean aliasesMatch = false;
|
||||
if(commandConfiguration.getAliases() != null) {
|
||||
aliasesMatch = commandConfiguration.getAliases().stream().anyMatch(s -> s.equalsIgnoreCase(name));
|
||||
}
|
||||
return aliasesMatch;
|
||||
}
|
||||
|
||||
public Command findCommand(String name) {
|
||||
Optional<Command> commandOptional = commands.stream().filter((Command o )-> {
|
||||
CommandConfiguration commandConfiguration = o.getConfiguration();
|
||||
|
||||
Reference in New Issue
Block a user