Adds tab-complete filtering #12

This commit is contained in:
2023-04-18 14:13:07 +02:00
parent cf0962ef70
commit 58e25bcb30
12 changed files with 65 additions and 26 deletions

View File

@ -76,4 +76,21 @@ public final class TabCompleteHelper {
return arenaProperties;
}
/**
* Finds tab complete values that contain the typed text
*
* @param values <p>The values to filter</p>
* @param typedText <p>The text the player has started typing</p>
* @return <p>The given string values that contain the player's typed text</p>
*/
public static List<String> filterMatchingContains(@NotNull List<String> values, @NotNull String typedText) {
List<String> configValues = new ArrayList<>();
for (String value : values) {
if (value.toLowerCase().contains(typedText.toLowerCase())) {
configValues.add(value);
}
}
return configValues;
}
}