Fixes some errors caused when calling a command without an argument
This commit is contained in:
parent
0ad953cc14
commit
4e44909f80
@ -19,7 +19,11 @@ public class TokenizedCommand implements CommandExecutor {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
arguments = Tokenizer.tokenize(String.join(" ", args));
|
arguments = Tokenizer.tokenize(String.join(" ", args));
|
||||||
|
if (args.length == 0) {
|
||||||
|
argumentSize = 0;
|
||||||
|
} else {
|
||||||
argumentSize = args[args.length - 1].isEmpty() ? arguments.size() : arguments.size() - 1;
|
argumentSize = args[args.length - 1].isEmpty() ? arguments.size() : arguments.size() - 1;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,11 @@ public class TokenizedTabCompleter implements TabCompleter {
|
|||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
||||||
arguments = Tokenizer.tokenize(String.join(" ", args));
|
arguments = Tokenizer.tokenize(String.join(" ", args));
|
||||||
|
if (args.length == 0) {
|
||||||
|
argumentSize = 0;
|
||||||
|
} else {
|
||||||
argumentSize = args[args.length - 1].isEmpty() ? arguments.size() : arguments.size() - 1;
|
argumentSize = args[args.length - 1].isEmpty() ? arguments.size() : arguments.size() - 1;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user