use of org.spongepowered.server.console.ConsoleCommandCompleter in project SpongeVanilla by SpongePowered.
the class MixinConsoleHandler method onRun.
@Inject(method = "run", at = @At("HEAD"), cancellable = true, remap = false)
private void onRun(CallbackInfo ci) {
final Terminal terminal = TerminalConsoleAppender.getTerminal();
if (terminal != null) {
LineReader reader = LineReaderBuilder.builder().appName("SpongeVanilla").terminal(terminal).completer(new ConsoleCommandCompleter(this.server)).build();
reader.unsetOpt(LineReader.Option.INSERT_TAB);
TerminalConsoleAppender.setReader(reader);
try {
String line;
while (!this.server.isServerStopped() && this.server.isServerRunning()) {
try {
line = reader.readLine("> ");
} catch (EndOfFileException e) {
// Continue reading after EOT
continue;
}
if (line == null) {
break;
}
line = line.trim();
if (!line.isEmpty()) {
this.server.addPendingCommand(line, this.server);
}
}
} catch (UserInterruptException e) {
this.server.initiateShutdown();
} finally {
TerminalConsoleAppender.setReader(null);
}
ci.cancel();
}
}
Aggregations