Skip to content

Commit

Permalink
Add import confirmation autocomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
TechnicallyCoded committed Nov 4, 2021
1 parent 4d1aeef commit 84ac124
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class Commands implements CommandExecutor, TabCompleter {

private String[] defaultOptions = new String[] {"restore", "forcebackup", "enable", "disable", "reload", "version", "import", "help"};
private String[] backupOptions = new String[] {"all", "player"};
private String[] importOptions = new String[] {"confirm"};

private HashMap<String, IRPCommand> subCommands = new HashMap<>();

Expand Down Expand Up @@ -63,13 +64,21 @@ public List<String> onTabComplete(CommandSender commandSender, Command command,
return suggestions;
} else if (args.length == 2) {
String[] opts;

if (args[0].equalsIgnoreCase("forcebackup") ||
args[0].equalsIgnoreCase("forcesave")) {
opts = this.backupOptions;

} else if (args[0].equalsIgnoreCase("import") &&
(ImportSubCmd.shouldShowConfirmOption() || args[1].toLowerCase().startsWith("c"))) {
opts = this.importOptions;

} else {
opts = null;
}

if (opts == null) return null;

ArrayList<String> suggestions = new ArrayList<>();
for (String option : opts) {
if (option.startsWith(args[1].toLowerCase()))
Expand Down

0 comments on commit 84ac124

Please sign in to comment.