mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2024-09-20 19:41:11 +02:00
Fix tab-completions on bukkit/spigot
This commit is contained in:
parent
ef7345bed9
commit
37ce1a15a6
@ -72,7 +72,12 @@ public Collection<BukkitCommand> getRootCommands(){
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onTabComplete(TabCompleteEvent evt) {
|
public void onTabComplete(TabCompleteEvent evt) {
|
||||||
try {
|
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<>();
|
List<String> completions = new ArrayList<>();
|
||||||
for (Suggestion suggestion : suggestions.getList()) {
|
for (Suggestion suggestion : suggestions.getList()) {
|
||||||
String text = suggestion.getText();
|
String text = suggestion.getText();
|
||||||
@ -84,7 +89,7 @@ public void onTabComplete(TabCompleteEvent evt) {
|
|||||||
|
|
||||||
if (!completions.isEmpty()) {
|
if (!completions.isEmpty()) {
|
||||||
completions.sort((s1, s2) -> s1.compareToIgnoreCase(s2));
|
completions.sort((s1, s2) -> s1.compareToIgnoreCase(s2));
|
||||||
evt.setCompletions(completions);
|
evt.getCompletions().addAll(completions);
|
||||||
}
|
}
|
||||||
} catch (InterruptedException ignore) {
|
} catch (InterruptedException ignore) {
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
|
Loading…
Reference in New Issue
Block a user