Fixes various bugs in commands

This commit is contained in:
2022-02-27 12:47:05 +01:00
parent 0f958f0908
commit 91d477b45a
9 changed files with 153 additions and 46 deletions

@ -15,6 +15,40 @@ public final class TabCompleteHelper {
}
/**
* 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;
}
/**
* Finds tab complete values that match the start of 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 start with the player's typed text</p>
*/
public static List<String> filterMatchingStartsWith(List<String> values, String typedText) {
List<String> 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
*
@ -49,7 +83,7 @@ public final class TabCompleteHelper {
for (String paidSignName : paidSignNames) {
quotedNames.add("\"" + paidSignName + "\"");
}
return new ArrayList<>(quotedNames);
return quotedNames;
}
/**