diff --git a/src/main/java/net/minecraftforge/server/console/ConsoleCommandCompleter.java b/src/main/java/net/minecraftforge/server/console/ConsoleCommandCompleter.java index af0216edb..fd73fbc3c 100644 --- a/src/main/java/net/minecraftforge/server/console/ConsoleCommandCompleter.java +++ b/src/main/java/net/minecraftforge/server/console/ConsoleCommandCompleter.java @@ -2,6 +2,7 @@ package net.minecraftforge.server.console; import static com.google.common.base.Preconditions.checkNotNull; +import java.util.Collections; import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; @@ -28,14 +29,9 @@ public final class ConsoleCommandCompleter implements Completer public int complete(String buffer, int cursor, List candidates) { int len = buffer.length(); - buffer = buffer.trim(); - if (buffer.isEmpty()) - { - return cursor; - } boolean prefix; - if (buffer.charAt(0) != '/') + if (buffer.isEmpty() || buffer.charAt(0) != '/') { buffer = '/' + buffer; prefix = false; @@ -59,6 +55,7 @@ public final class ConsoleCommandCompleter implements Completer try { List completions = tabComplete.get(); + Collections.sort(completions); if (prefix) { candidates.addAll(completions); @@ -76,6 +73,10 @@ public final class ConsoleCommandCompleter implements Completer { return cursor - len; } + else if (prefix) + { + return cursor - len + pos + 1; + } else { return cursor - len + pos; diff --git a/src/main/java/net/minecraftforge/server/console/TerminalHandler.java b/src/main/java/net/minecraftforge/server/console/TerminalHandler.java index 3c9f6af28..142b32bc7 100644 --- a/src/main/java/net/minecraftforge/server/console/TerminalHandler.java +++ b/src/main/java/net/minecraftforge/server/console/TerminalHandler.java @@ -34,14 +34,15 @@ public final class TerminalHandler try { line = reader.readLine("> "); - - if (line != null) + if (line == null) { - line = line.trim(); - if (!line.isEmpty()) - { - server.addPendingCommand(line, server); - } + break; + } + + line = line.trim(); + if (!line.isEmpty()) + { + server.addPendingCommand(line, server); } } catch (IOException e)