diff options
author | Dinnerbone <dinnerbone@dinnerbone.com> | 2011-02-25 16:12:38 +0000 |
---|---|---|
committer | Dinnerbone <dinnerbone@dinnerbone.com> | 2011-02-25 16:12:38 +0000 |
commit | 57338bee5205c157c1cf83bf50ab513f9d3f69d9 (patch) | |
tree | aa178c1cd5d0fc35fba7e76b07f1a72f71637bbc /src/main/java/net | |
parent | 659fa9eaf9ccfcda12ee9bc4b7dfa589884927da (diff) | |
download | craftbukkit-57338bee5205c157c1cf83bf50ab513f9d3f69d9.tar craftbukkit-57338bee5205c157c1cf83bf50ab513f9d3f69d9.tar.gz craftbukkit-57338bee5205c157c1cf83bf50ab513f9d3f69d9.tar.lz craftbukkit-57338bee5205c157c1cf83bf50ab513f9d3f69d9.tar.xz craftbukkit-57338bee5205c157c1cf83bf50ab513f9d3f69d9.zip |
Much better console interaction. History, no more losing the command, colours, inline editing, etc. Shorter log output to console (but not to file).
Diffstat (limited to 'src/main/java/net')
4 files changed, 57 insertions, 7 deletions
diff --git a/src/main/java/net/minecraft/server/ConsoleLogManager.java b/src/main/java/net/minecraft/server/ConsoleLogManager.java index 6de400b4..641c8ca7 100644 --- a/src/main/java/net/minecraft/server/ConsoleLogManager.java +++ b/src/main/java/net/minecraft/server/ConsoleLogManager.java @@ -6,6 +6,9 @@ import java.util.logging.Level; import java.util.logging.Logger; import java.util.logging.Handler; // CraftBukkit +import jline.ConsoleReader; +import org.bukkit.craftbukkit.util.ShortConsoleLogFormatter; +import org.bukkit.craftbukkit.util.TerminalConsoleHandler; public class ConsoleLogManager { @@ -14,11 +17,12 @@ public class ConsoleLogManager { public ConsoleLogManager() {} - public static void a() { + // Craftbukkit - change of method signature! + public static void a(ConsoleReader reader) { ConsoleLogFormatter consolelogformatter = new ConsoleLogFormatter(); a.setUseParentHandlers(false); - ConsoleHandler consolehandler = new ConsoleHandler(); + ConsoleHandler consolehandler = new TerminalConsoleHandler(reader); // CraftBukkit start for (Handler handler: global.getHandlers()) { @@ -26,7 +30,7 @@ public class ConsoleLogManager { } // CraftBukkit end - consolehandler.setFormatter(consolelogformatter); + consolehandler.setFormatter(new ShortConsoleLogFormatter()); // Craftbukkit a.addHandler(consolehandler); global.addHandler(consolehandler); // CraftBukkit diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java index 3daaa767..71e6a327 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -15,10 +15,12 @@ import java.util.logging.Logger; // CraftBukkit start import java.io.PrintStream; import java.net.UnknownHostException; +import jline.ConsoleReader; import joptsimple.OptionSet; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.LoggerOutputStream; +import org.bukkit.craftbukkit.command.ColouredConsoleSender; import org.bukkit.craftbukkit.scheduler.CraftScheduler; import org.bukkit.event.Event; import org.bukkit.event.world.WorldEvent; @@ -50,12 +52,21 @@ public class MinecraftServer implements Runnable, ICommandListener { public List<WorldServer> worlds = new ArrayList<WorldServer>(); public CraftServer server; public OptionSet options; - public ConsoleCommandSender console; + public ColouredConsoleSender console; + public ConsoleReader reader; // Craftbukkit end public MinecraftServer(OptionSet options) { // CraftBukkit - adds argument OptionSet new ThreadSleepForever(this); - this.options = options; // CraftBukkit + + // CraftBukkit start + this.options = options; + try { + this.reader = new ConsoleReader(); + } catch (IOException ex) { + Logger.getLogger(MinecraftServer.class.getName()).log(Level.SEVERE, null, ex); + } + // CraftBukkit end } private boolean d() throws UnknownHostException { // CraftBukkit - added throws UnknownHostException @@ -64,7 +75,7 @@ public class MinecraftServer implements Runnable, ICommandListener { threadcommandreader.setDaemon(true); threadcommandreader.start(); - ConsoleLogManager.a(); + ConsoleLogManager.a(reader); // Craftbukkit // CraftBukkit start System.setOut(new PrintStream(new LoggerOutputStream(a, Level.INFO), true)); diff --git a/src/main/java/net/minecraft/server/ServerConfigurationManager.java b/src/main/java/net/minecraft/server/ServerConfigurationManager.java index 7f26ef18..15a1e554 100644 --- a/src/main/java/net/minecraft/server/ServerConfigurationManager.java +++ b/src/main/java/net/minecraft/server/ServerConfigurationManager.java @@ -17,6 +17,7 @@ import org.bukkit.Location; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.craftbukkit.command.ColouredConsoleSender; import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.Event.Type; @@ -48,7 +49,7 @@ public class ServerConfigurationManager { public ServerConfigurationManager(MinecraftServer minecraftserver) { minecraftserver.server = new CraftServer(minecraftserver, this); - minecraftserver.console = new ConsoleCommandSender(minecraftserver.server); + minecraftserver.console = new ColouredConsoleSender(minecraftserver.server); server = minecraftserver.server; // CraftBukkit end diff --git a/src/main/java/net/minecraft/server/ThreadCommandReader.java b/src/main/java/net/minecraft/server/ThreadCommandReader.java new file mode 100644 index 00000000..7277758e --- /dev/null +++ b/src/main/java/net/minecraft/server/ThreadCommandReader.java @@ -0,0 +1,34 @@ +package net.minecraft.server; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.logging.Level; +import java.util.logging.Logger; +import jline.ConsoleReader; + +public class ThreadCommandReader extends Thread { + + final MinecraftServer a; + + public ThreadCommandReader(MinecraftServer minecraftserver) { + this.a = minecraftserver; + } + + public void run() { + // Craftbukkit start - whole method, nuked to oblivion! :o + + try { + ConsoleReader reader = a.reader; + String line = null; + + while ((!this.a.g) && (MinecraftServer.a(this.a)) && ((line = reader.readLine()) != null)) { + this.a.a(line, (ICommandListener) this.a); + } + + } catch (IOException ex) { + Logger.getLogger(ThreadCommandReader.class.getName()).log(Level.SEVERE, null, ex); + } + // Craftbukkit end + } +} |