Fix tab-completions on bukkit/spigot

This commit is contained in:
Blue (Lukas Rieger) 2020-08-23 14:04:42 +02:00
parent ef7345bed9
commit 37ce1a15a6

View File

@ -72,7 +72,12 @@ public Collection<BukkitCommand> getRootCommands(){
@EventHandler
public void onTabComplete(TabCompleteEvent evt) {
try {
Suggestions suggestions = dispatcher.getCompletionSuggestions(dispatcher.parse(evt.getBuffer().substring(1), evt.getSender())).get(100, TimeUnit.MILLISECONDS);
String input = evt.getBuffer();
if (input.length() > 0 && input.charAt(0) == '/') {
input = input.substring(1);
}
Suggestions suggestions = dispatcher.getCompletionSuggestions(dispatcher.parse(input, evt.getSender())).get(100, TimeUnit.MILLISECONDS);
List<String> completions = new ArrayList<>();
for (Suggestion suggestion : suggestions.getList()) {
String text = suggestion.getText();
@ -84,7 +89,7 @@ public void onTabComplete(TabCompleteEvent evt) {
if (!completions.isEmpty()) {
completions.sort((s1, s2) -> s1.compareToIgnoreCase(s2));
evt.setCompletions(completions);
evt.getCompletions().addAll(completions);
}
} catch (InterruptedException ignore) {
Thread.currentThread().interrupt();