Uses KnarLib for tab-completion filtering

This commit is contained in:
Kristian Knarvik 2022-11-06 23:05:16 +01:00
parent 2846100497
commit fc70b0a582
2 changed files with 1 additions and 33 deletions

View File

@ -14,7 +14,7 @@ import org.jetbrains.annotations.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import static net.knarcraft.minstrel.util.TabCompletionHelper.filterMatchingContains; import static net.knarcraft.knarlib.util.TabCompletionHelper.filterMatchingContains;
public class MinstrelTabCompleter implements TabCompleter { public class MinstrelTabCompleter implements TabCompleter {

View File

@ -1,32 +0,0 @@
package net.knarcraft.minstrel.util;
import java.util.ArrayList;
import java.util.List;
/**
* A helper class for tab-completion
*/
public final class TabCompletionHelper {
private TabCompletionHelper() {
}
/**
* 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(List<String> values, String typedText) {
List<String> configValues = new ArrayList<>();
for (String value : values) {
if (value.toLowerCase().contains(typedText.toLowerCase())) {
configValues.add(value);
}
}
return configValues;
}
}