Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-25 15:50:14 +01:00
Add tab completion to Geyser standalone
Dieser Commit ist enthalten in:
Ursprung
8827173c5b
Commit
521b9f3dce
@ -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();
|
||||
|
@ -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<GeyserCommandSource, ? extends Suggestion> suggestionsFor(GeyserCommandSource source, String input) {
|
||||
return cloud.suggestionFactory().suggestImmediately(source, input);
|
||||
}
|
||||
|
||||
public void export(GeyserSession session, List<CommandData> bedrockCommands, Set<String> knownAliases) {
|
||||
cloud.commandTree().rootNodes().forEach(commandTree -> {
|
||||
var command = commandTree.command();
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren