Skip to content

Commit

Permalink
Exclude all empty args for call of CommandTicTacToe.extractIntegerArgs()
Browse files Browse the repository at this point in the history
  • Loading branch information
lscgh committed Feb 6, 2024
1 parent 4715477 commit f89f1ff
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,11 @@ public List<String> onTabComplete(CommandSender sender, Command command, String

if(completions.isEmpty()) completions.add("(no available players)");
} else if(argList.size() == CommandTicTacToe.WIN_REQUIRED_AMOUNT_ARG_INDEX) {
int integerArgs[] = CommandTicTacToe.extractIntegerArgs(Arrays.copyOf(argList.toArray(), argList.size(), String[].class));
ArrayList<String> listWithNoEmptyArgsAtAll = new ArrayList<String>();
for(String arg: args) listWithNoEmptyArgsAtAll.add(arg);
listWithNoEmptyArgsAtAll.removeIf((arg) -> arg.isEmpty());

int integerArgs[] = CommandTicTacToe.extractIntegerArgs(Arrays.copyOf(listWithNoEmptyArgsAtAll.toArray(), listWithNoEmptyArgsAtAll.size(), String[].class));
int maxDimension = Math.max(integerArgs[0], Math.max(integerArgs[1], integerArgs[2]));
completions.add("" + maxDimension);
} else if(argList.size() < CommandTicTacToe.MAX_VALID_ARG_COUNT) {
Expand Down

0 comments on commit f89f1ff

Please sign in to comment.