Skip to content

Commit

Permalink
chore: Bumped version to 0.7.1b5-SNAPSHOT
Browse files Browse the repository at this point in the history
feat(command): Added addSubCommand() to BaseCommand.java
  • Loading branch information
LeeGodSRC committed Apr 5, 2024
1 parent 34292f8 commit 11acc44
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
3 changes: 1 addition & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
#

# Fairy
fairy.version = 0.7.1b4-SNAPSHOT
gradle-plugin.version = 1.2.0b9
fairy.version = 0.7.1b5-SNAPSHOT

mongojack.version = 4.2.0
mongodb.version = 4.2.3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,23 @@ public void onError(CommandContext commandContext, Throwable throwable) {

@Override
public boolean canAccess(CommandContext commandContext) {
if (this.permission == null || this.permission.length() == 0) {
if (this.permission == null || this.permission.isEmpty()) {
return true;
}

return commandContext.hasPermission(this.permission);
}

protected void addSubCommand(@NotNull String[] commandNames, @NotNull ICommand subCommand) {
for (String commandName : commandNames) {
this.subCommands
.computeIfAbsent(commandName.toLowerCase(), k -> ConcurrentHashMap.newKeySet())
.add(subCommand);
}
this.maxParameterCount = Math.max(subCommand.getMaxParameterCount(), this.maxParameterCount);
this.requireInputParameterCount = Math.max(subCommand.getRequireInputParameterCount(), this.requireInputParameterCount);
}

public void init() {
this.init(this.getClass().getAnnotation(Command.class));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,13 +265,7 @@ private void initialiseSubCommand(@Nullable Command command, BaseCommand subComm
subCommand.init();
}

for (String commandName : subCommand.getCommandNames()) {
baseCommand.subCommands
.computeIfAbsent(commandName.toLowerCase(), k -> ConcurrentHashMap.newKeySet())
.add(subCommand);
}
baseCommand.maxParameterCount = Math.max(subCommand.getMaxParameterCount(), baseCommand.maxParameterCount);
baseCommand.requireInputParameterCount = Math.max(subCommand.getRequireInputParameterCount(), baseCommand.requireInputParameterCount);
baseCommand.addSubCommand(subCommand.getCommandNames(), subCommand);
}

}

0 comments on commit 11acc44

Please sign in to comment.