diff --git a/proxy/src/main/java/net/md_5/bungee/command/ConsoleCommandCompleter.java b/proxy/src/main/java/net/md_5/bungee/command/ConsoleCommandCompleter.java index bd52d880b..3e5ca3947 100644 --- a/proxy/src/main/java/net/md_5/bungee/command/ConsoleCommandCompleter.java +++ b/proxy/src/main/java/net/md_5/bungee/command/ConsoleCommandCompleter.java @@ -2,6 +2,9 @@ package net.md_5.bungee.command; import java.util.ArrayList; import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.stream.Collectors; import jline.console.completer.Completer; import lombok.RequiredArgsConstructor; import net.md_5.bungee.api.ProxyServer; @@ -15,11 +18,21 @@ public class ConsoleCommandCompleter implements Completer @Override public int complete(String buffer, int cursor, List candidates) { - List suggestions = new ArrayList<>(); - proxy.getPluginManager().dispatchCommand( proxy.getConsole(), buffer, suggestions ); - candidates.addAll( suggestions ); - int lastSpace = buffer.lastIndexOf( ' ' ); + if ( lastSpace == -1 ) + { + String lowerCase = buffer.toLowerCase( Locale.ROOT ); + candidates.addAll( proxy.getPluginManager().getCommands().stream() + .map( Map.Entry::getKey ) + .filter( (name) -> name.toLowerCase( Locale.ROOT ).startsWith( lowerCase ) ) + .collect( Collectors.toList() ) ); + } else + { + List suggestions = new ArrayList<>(); + proxy.getPluginManager().dispatchCommand( proxy.getConsole(), buffer, suggestions ); + candidates.addAll( suggestions ); + } + return ( lastSpace == -1 ) ? cursor - buffer.length() : cursor - ( buffer.length() - lastSpace - 1 ); } }