diff --git a/bootstrap/standalone/src/main/java/org/geysermc/geyser/platform/standalone/GeyserStandaloneLogger.java b/bootstrap/standalone/src/main/java/org/geysermc/geyser/platform/standalone/GeyserStandaloneLogger.java index 21e6a5e82..b614a7b23 100644 --- a/bootstrap/standalone/src/main/java/org/geysermc/geyser/platform/standalone/GeyserStandaloneLogger.java +++ b/bootstrap/standalone/src/main/java/org/geysermc/geyser/platform/standalone/GeyserStandaloneLogger.java @@ -33,10 +33,24 @@ import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.command.GeyserCommandSource; import org.geysermc.geyser.text.ChatColor; +import org.jline.reader.Candidate; +import org.jline.reader.LineReader; +import org.jline.reader.LineReaderBuilder; @Slf4j public class GeyserStandaloneLogger extends SimpleTerminalConsole implements GeyserLogger, GeyserCommandSource { + @Override + protected LineReader buildReader(LineReaderBuilder builder) { + builder.completer((reader, line, candidates) -> { + var suggestions = GeyserImpl.getInstance().commandRegistry().suggestionsFor(this, line.line()); + for (var suggestion : suggestions.list()) { + candidates.add(new Candidate(suggestion.suggestion())); + } + }); + return super.buildReader(builder); + } + @Override protected boolean isRunning() { return !GeyserImpl.getInstance().isShuttingDown(); diff --git a/core/src/main/java/org/geysermc/geyser/command/CommandRegistry.java b/core/src/main/java/org/geysermc/geyser/command/CommandRegistry.java index 9de7582a5..5d44016c9 100644 --- a/core/src/main/java/org/geysermc/geyser/command/CommandRegistry.java +++ b/core/src/main/java/org/geysermc/geyser/command/CommandRegistry.java @@ -68,6 +68,8 @@ import org.incendo.cloud.parser.standard.EnumParser; import org.incendo.cloud.parser.standard.IntegerParser; import org.incendo.cloud.parser.standard.LiteralParser; import org.incendo.cloud.parser.standard.StringArrayParser; +import org.incendo.cloud.suggestion.Suggestion; +import org.incendo.cloud.suggestion.Suggestions; import java.util.ArrayList; import java.util.Collection; @@ -320,6 +322,10 @@ public class CommandRegistry implements EventRegistrar { cloud.commandExecutor().executeCommand(source, command); } + public Suggestions suggestionsFor(GeyserCommandSource source, String input) { + return cloud.suggestionFactory().suggestImmediately(source, input); + } + public void export(GeyserSession session, List bedrockCommands, Set knownAliases) { cloud.commandTree().rootNodes().forEach(commandTree -> { var command = commandTree.command();