Skip to content

Commit

Permalink
Add CommandSender to ArgsTester
Browse files Browse the repository at this point in the history
  • Loading branch information
notTamion committed Jan 4, 2024
1 parent eaceaf7 commit 0e7f49c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/main/java/de/tamion/commandclip/GenericCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,17 @@ public interface TabCompletionLogic {
}

/**
* See {@link #test(String, String[])}
* See {@link #test(CommandSender, String, String[])}
*/
public interface ArgTester {
/**
* The Logic that gets run when a user tries to execute a command
*
* @param sender the CommandSender
* @param alias the alias used to call the command
* @param args truncated Args to not include subcommands
* @return null if Args passed test or usage String to be sent to the user
*/
String test(String alias, String[] args);
String test(CommandSender sender, String alias, String[] args);
}
}
2 changes: 1 addition & 1 deletion src/main/java/de/tamion/commandclip/InternalCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public boolean execute(@NotNull CommandSender sender, @NotNull String commandLab
}

String usage;
if(command.argTester != null && (usage = command.argTester.test(commandLabel, args)) != null) {
if(command.argTester != null && (usage = command.argTester.test(sender, commandLabel, args)) != null) {
sender.sendMessage(usage);
return false;
}
Expand Down

0 comments on commit 0e7f49c

Please sign in to comment.