mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-28 18:31:24 +01:00
Add Convenience method for tab-completion and correct indentation.
This commit is contained in:
parent
5f82584072
commit
1a73b65d4a
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -128,4 +129,29 @@ public class CommandUtil {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method to map all matches within one of the String[] arrays
|
||||
* to its first element.<br>
|
||||
* Do note that this does exact-case comparison, for case insensitive
|
||||
* comparison use a lower-case model and pass a lower-case input.
|
||||
*
|
||||
* @param input
|
||||
* @param model
|
||||
* Should be lower case (!).
|
||||
* @return Always returns a modifiable list.
|
||||
*/
|
||||
public static List<String> getTabMatches(final String input, final String[][] model) {
|
||||
final List<String> res = new LinkedList<String>();
|
||||
for (final String[] choices : model) {
|
||||
for (final String choice : choices) {
|
||||
if (choice.startsWith(input)) {
|
||||
res.add(choices[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user