package net.knarcraft.paidsigns.utility; import net.knarcraft.paidsigns.PaidSigns; import java.util.ArrayList; import java.util.List; import java.util.Set; /** * A helper class for providing common tab complete options */ public final class TabCompleteHelper { private TabCompleteHelper() { } /** * Finds tab complete values that contain the typed text * * @param values

The values to filter

* @param typedText

The text the player has started typing

* @return

The given string values that contain the player's typed text

*/ public static List filterMatchingContains(List values, String typedText) { List configValues = new ArrayList<>(); for (String value : values) { if (value.toLowerCase().contains(typedText.toLowerCase())) { configValues.add(value); } } return configValues; } /** * Finds tab complete values that match the start of the typed text * * @param values

The values to filter

* @param typedText

The text the player has started typing

* @return

The given string values that start with the player's typed text

*/ public static List filterMatchingStartsWith(List values, String typedText) { List configValues = new ArrayList<>(); for (String value : values) { if (value.toLowerCase().startsWith(typedText.toLowerCase())) { configValues.add(value); } } return configValues; } /** * Gets the available boolean values for tab completion * * @return

The available boolean values

*/ public static List getBooleans() { List booleans = new ArrayList<>(); booleans.add("true"); booleans.add("false"); return booleans; } /** * Gets the available option states for tab completion * * @return

The available option states

*/ public static List getOptionStates() { List optionStates = getBooleans(); optionStates.add("default"); return optionStates; } /** * Gets the names of all registered paid signs * * @return

The names of all registered paid signs

*/ public static List getPaidSignNames() { Set paidSignNames = PaidSigns.getInstance().getSignManager().getAllPaidSigns().keySet(); List quotedNames = new ArrayList<>(paidSignNames.size()); for (String paidSignName : paidSignNames) { quotedNames.add("\"" + paidSignName + "\""); } return quotedNames; } /** * Gets all the choices for lines on a sign * * @return

All the line indices of a sign

*/ public static List getSignLines() { List lines = new ArrayList<>(); for (int i = 1; i < 5; i++) { lines.add(String.valueOf(i)); } return lines; } /** * Gets some valid costs as example values * * @return

Some valid costs

*/ public static List getCosts() { List costs = new ArrayList<>(); costs.add("1"); costs.add("5"); costs.add("10"); costs.add("15"); return costs; } /** * Gets some example paid sign names for auto-completion * * @return

Some example paid sign names

*/ public static List getExamplePaidSignNames() { List names = new ArrayList<>(); names.add("sign1"); names.add("\"lift up sign\""); names.add("\"lift down sign\""); return names; } /** * Gets some example condition matching strings for tab completion * * @return

Some example "stringToMatch" values

*/ public static List getExampleConditionStrings() { List conditionStrings = new ArrayList<>(); conditionStrings.add("[Gate]"); conditionStrings.add("\"[Lift Up]\""); conditionStrings.add("\"[Lift Down]\""); return conditionStrings; } }