From 5651b3932855c1c85bb118c1df50335d3a05a0f4 Mon Sep 17 00:00:00 2001 From: Pyrbu Date: Tue, 13 Jun 2023 23:58:10 +0200 Subject: [PATCH] fix action add completion --- .../commands/action/ActionAddCommand.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/plugin/src/main/java/lol/pyr/znpcsplus/commands/action/ActionAddCommand.java b/plugin/src/main/java/lol/pyr/znpcsplus/commands/action/ActionAddCommand.java index 3109c1b..1d4efba 100644 --- a/plugin/src/main/java/lol/pyr/znpcsplus/commands/action/ActionAddCommand.java +++ b/plugin/src/main/java/lol/pyr/znpcsplus/commands/action/ActionAddCommand.java @@ -25,10 +25,10 @@ public class ActionAddCommand implements CommandHandler { @Override public void run(CommandContext context) throws CommandExecutionException { List commands = actionRegistry.getCommands(); - context.setUsage(context.getLabel() + " action add ..."); + context.setUsage(context.getLabel() + " action add "); String sub = context.popString(); for (InteractionCommandHandler command : commands) if (command.getSubcommandName().equalsIgnoreCase(sub)) { - context.setUsage(context.getLabel() + " action add "); + context.setUsage(context.getLabel() + " action add"); command.run(context); return; } @@ -38,12 +38,14 @@ public class ActionAddCommand implements CommandHandler { @Override public List suggest(CommandContext context) throws CommandExecutionException { - if (context.argSize() == 1) return context.suggestCollection(npcRegistry.getModifiableIds()); List commands = actionRegistry.getCommands(); - if (context.argSize() == 2) return context.suggestStream(commands.stream().map(InteractionCommandHandler::getSubcommandName)); - context.popString(); - String sub = context.popString(); - for (InteractionCommandHandler command : commands) if (command.getSubcommandName().equalsIgnoreCase(sub)) return command.suggest(context); + if (context.argSize() == 1) return context.suggestStream(commands.stream().map(InteractionCommandHandler::getSubcommandName)); + if (context.argSize() == 2) return context.suggestCollection(npcRegistry.getModifiableIds()); + if (context.argSize() >= 3) { + String sub = context.popString(); + context.popString(); + for (InteractionCommandHandler command : commands) if (command.getSubcommandName().equalsIgnoreCase(sub)) return command.suggest(context); + } return Collections.emptyList(); } }