From 2f451a722816967065daf47626ed2167be5b8e3b Mon Sep 17 00:00:00 2001 From: Eric Date: Sat, 21 Mar 2020 22:08:07 +0100 Subject: [PATCH] Fix edit command tab completion --- .../java/de/epiceric/shopchest/command/EditSubCommand.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/src/main/java/de/epiceric/shopchest/command/EditSubCommand.java b/core/src/main/java/de/epiceric/shopchest/command/EditSubCommand.java index 99f35ed..1b0d657 100644 --- a/core/src/main/java/de/epiceric/shopchest/command/EditSubCommand.java +++ b/core/src/main/java/de/epiceric/shopchest/command/EditSubCommand.java @@ -123,6 +123,7 @@ public class EditSubCommand extends SubCommand { public List onTabComplete(CommandSender sender, String... args) { String[] argsWithoutLast = Arrays.copyOf(args, Math.max(0, args.length - 1)); + boolean isItemSet = !getNamedArgs(ITEM_ARGS, argsWithoutLast).isEmpty(); boolean isAmountSet = !getNamedArgs(AMOUNT_ARGS, argsWithoutLast).isEmpty(); boolean isBuyPriceSet = !getNamedArgs(BUY_PRICE_ARGS, argsWithoutLast).isEmpty(); boolean isSellPriceSet = !getNamedArgs(SELL_PRICE_ARGS, argsWithoutLast).isEmpty(); @@ -131,6 +132,10 @@ public class EditSubCommand extends SubCommand { List ret = new ArrayList<>(); + if (!isItemSet) { + ITEM_ARGS.stream().filter(arg -> arg.startsWith(lastArg)).findFirst().ifPresent(ret::add); + } + if (!isAmountSet) { AMOUNT_ARGS.stream().filter(arg -> arg.startsWith(lastArg)).findFirst().ifPresent(ret::add); }