package net.knarcraft.paidsigns.command; import net.knarcraft.paidsigns.utility.TabCompleteHelper; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.List; /** * The tab completer for the add paid sign condition command */ public class AddConditionTabCompleter extends TokenizedTabCompleter { private List lineIndices; private List stringsToMatch; private List booleans; private List optionStates; @Nullable @Override public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) { super.onTabComplete(sender, command, alias, args); if (lineIndices == null) { initializeValues(); } if (argumentSize == 1) { return TabCompleteHelper.filterMatchingStartsWith(TabCompleteHelper.getPaidSignNames(), arguments.get(0)); } else if (argumentSize == 2) { return TabCompleteHelper.filterMatchingStartsWith(this.lineIndices, arguments.get(1)); } else if (argumentSize == 3) { return TabCompleteHelper.filterMatchingStartsWith(stringsToMatch, arguments.get(2)); } else if (argumentSize == 4) { return TabCompleteHelper.filterMatchingStartsWith(booleans, arguments.get(3)); } else if (argumentSize == 5) { return TabCompleteHelper.filterMatchingStartsWith(optionStates, arguments.get(4)); } else if (argumentSize == 6) { return TabCompleteHelper.filterMatchingStartsWith(optionStates, arguments.get(5)); } return new ArrayList<>(); } /** * Initializes the values available for tab completion */ private void initializeValues() { lineIndices = TabCompleteHelper.getSignLines(); stringsToMatch = TabCompleteHelper.getExampleConditionStrings(); booleans = TabCompleteHelper.getBooleans(); optionStates = TabCompleteHelper.getOptionStates(); } }