summaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authorEdGruberman <ed@rjump.com>2012-03-14 13:59:14 -0700
committerTravis Watkins <amaranth@ubuntu.com>2012-05-15 23:27:51 -0500
commit31d488a3861e60f44703958e36d6eabe422f5f41 (patch)
tree230daedf4be15716c087560cd506afbc3aabb228 /src/main/java/org
parentcbd20ec9eae853ccd51d5395b5c0a180fa8c9499 (diff)
downloadcraftbukkit-31d488a3861e60f44703958e36d6eabe422f5f41.tar
craftbukkit-31d488a3861e60f44703958e36d6eabe422f5f41.tar.gz
craftbukkit-31d488a3861e60f44703958e36d6eabe422f5f41.tar.lz
craftbukkit-31d488a3861e60f44703958e36d6eabe422f5f41.tar.xz
craftbukkit-31d488a3861e60f44703958e36d6eabe422f5f41.zip
Update to jline 2. Fixes BUKKIT-717
JLine 2 allows for better color matching in the console and support for colors in console on Windows. Hopefully provides better performance as well.
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftServer.java2
-rw-r--r--src/main/java/org/bukkit/craftbukkit/command/ColouredConsoleSender.java51
-rw-r--r--src/main/java/org/bukkit/craftbukkit/util/TerminalConsoleHandler.java10
3 files changed, 35 insertions, 28 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 04d825d6..00a82f2f 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -120,7 +120,7 @@ import com.avaje.ebeaninternal.server.lib.sql.TransactionIsolation;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.MapMaker;
-import jline.ConsoleReader;
+import jline.console.ConsoleReader;
public final class CraftServer implements Server {
private final String serverName = "CraftBukkit";
diff --git a/src/main/java/org/bukkit/craftbukkit/command/ColouredConsoleSender.java b/src/main/java/org/bukkit/craftbukkit/command/ColouredConsoleSender.java
index c5c817c8..a54b2fae 100644
--- a/src/main/java/org/bukkit/craftbukkit/command/ColouredConsoleSender.java
+++ b/src/main/java/org/bukkit/craftbukkit/command/ColouredConsoleSender.java
@@ -2,8 +2,9 @@ package org.bukkit.craftbukkit.command;
import java.util.EnumMap;
import java.util.Map;
-import jline.ANSIBuffer.ANSICodes;
-import jline.ConsoleReader;
+import org.fusesource.jansi.Ansi;
+import org.fusesource.jansi.Ansi.Attribute;
+import jline.console.ConsoleReader;
import jline.Terminal;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@@ -21,37 +22,43 @@ public class ColouredConsoleSender extends CraftConsoleCommandSender {
this.reader = ((CraftServer) getServer()).getReader();
this.terminal = reader.getTerminal();
- replacements.put(ChatColor.BLACK, ANSICodes.attrib(0));
- replacements.put(ChatColor.DARK_BLUE, ANSICodes.attrib(34));
- replacements.put(ChatColor.DARK_GREEN, ANSICodes.attrib(32));
- replacements.put(ChatColor.DARK_AQUA, ANSICodes.attrib(36));
- replacements.put(ChatColor.DARK_RED, ANSICodes.attrib(31));
- replacements.put(ChatColor.DARK_PURPLE, ANSICodes.attrib(35));
- replacements.put(ChatColor.GOLD, ANSICodes.attrib(33));
- replacements.put(ChatColor.GRAY, ANSICodes.attrib(37));
- replacements.put(ChatColor.DARK_GRAY, ANSICodes.attrib(0));
- replacements.put(ChatColor.BLUE, ANSICodes.attrib(34));
- replacements.put(ChatColor.GREEN, ANSICodes.attrib(32));
- replacements.put(ChatColor.AQUA, ANSICodes.attrib(36));
- replacements.put(ChatColor.RED, ANSICodes.attrib(31));
- replacements.put(ChatColor.LIGHT_PURPLE, ANSICodes.attrib(35));
- replacements.put(ChatColor.YELLOW, ANSICodes.attrib(33));
- replacements.put(ChatColor.WHITE, ANSICodes.attrib(37));
+ replacements.put(ChatColor.BLACK, Ansi.ansi().fg(Ansi.Color.BLACK).toString());
+ replacements.put(ChatColor.DARK_BLUE, Ansi.ansi().fg(Ansi.Color.BLUE).toString());
+ replacements.put(ChatColor.DARK_GREEN, Ansi.ansi().fg(Ansi.Color.GREEN).toString());
+ replacements.put(ChatColor.DARK_AQUA, Ansi.ansi().fg(Ansi.Color.CYAN).toString());
+ replacements.put(ChatColor.DARK_RED, Ansi.ansi().fg(Ansi.Color.RED).toString());
+ replacements.put(ChatColor.DARK_PURPLE, Ansi.ansi().fg(Ansi.Color.MAGENTA).toString());
+ replacements.put(ChatColor.GOLD, Ansi.ansi().fg(Ansi.Color.YELLOW).bold().toString());
+ replacements.put(ChatColor.GRAY, Ansi.ansi().fg(Ansi.Color.WHITE).toString());
+ replacements.put(ChatColor.DARK_GRAY, Ansi.ansi().fg(Ansi.Color.BLACK).bold().toString());
+ replacements.put(ChatColor.BLUE, Ansi.ansi().fg(Ansi.Color.BLUE).bold().toString());
+ replacements.put(ChatColor.GREEN, Ansi.ansi().fg(Ansi.Color.GREEN).bold().toString());
+ replacements.put(ChatColor.AQUA, Ansi.ansi().fg(Ansi.Color.CYAN).bold().toString());
+ replacements.put(ChatColor.RED, Ansi.ansi().fg(Ansi.Color.RED).bold().toString());
+ replacements.put(ChatColor.LIGHT_PURPLE, Ansi.ansi().fg(Ansi.Color.MAGENTA).bold().toString());
+ replacements.put(ChatColor.YELLOW, Ansi.ansi().fg(Ansi.Color.YELLOW).bold().toString());
+ replacements.put(ChatColor.WHITE, Ansi.ansi().fg(Ansi.Color.WHITE).bold().toString());
+ replacements.put(ChatColor.MAGIC, Ansi.ansi().a(Attribute.BLINK_SLOW).toString());
+ replacements.put(ChatColor.BOLD, Ansi.ansi().a(Attribute.UNDERLINE_DOUBLE).toString());
+ replacements.put(ChatColor.STRIKETHROUGH, Ansi.ansi().a(Attribute.STRIKETHROUGH_ON).toString());
+ replacements.put(ChatColor.UNDERLINE, Ansi.ansi().a(Attribute.UNDERLINE).toString());
+ replacements.put(ChatColor.ITALIC, Ansi.ansi().a(Attribute.ITALIC).toString());
+ replacements.put(ChatColor.RESET, Ansi.ansi().a(Attribute.RESET).fg(Ansi.Color.DEFAULT).toString());
}
@Override
public void sendMessage(String message) {
- if (terminal.isANSISupported()) {
+ if (terminal.isAnsiSupported()) {
if (!conversationTracker.isConversingModaly()) {
String result = message;
for (ChatColor color : colors) {
if (replacements.containsKey(color)) {
- result = result.replaceAll(color.toString(), replacements.get(color));
+ result = result.replaceAll("(?i)" + color.toString(), replacements.get(color));
} else {
- result = result.replaceAll(color.toString(), "");
+ result = result.replaceAll("(?i)" + color.toString(), "");
}
}
- System.out.println(result + ANSICodes.attrib(0));
+ System.out.println(result + Ansi.ansi().reset().toString());
}
} else {
super.sendMessage(message);
diff --git a/src/main/java/org/bukkit/craftbukkit/util/TerminalConsoleHandler.java b/src/main/java/org/bukkit/craftbukkit/util/TerminalConsoleHandler.java
index 111123f5..57dab074 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/TerminalConsoleHandler.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/TerminalConsoleHandler.java
@@ -4,7 +4,7 @@ import java.io.IOException;
import java.util.logging.ConsoleHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
-import jline.ConsoleReader;
+import jline.console.ConsoleReader;
import org.bukkit.craftbukkit.Main;
public class TerminalConsoleHandler extends ConsoleHandler {
@@ -19,15 +19,15 @@ public class TerminalConsoleHandler extends ConsoleHandler {
public synchronized void flush() {
try {
if (Main.useJline) {
- reader.printString(ConsoleReader.RESET_LINE + "");
- reader.flushConsole();
+ reader.print(ConsoleReader.RESET_LINE + "");
+ reader.flush();
super.flush();
try {
reader.drawLine();
} catch (Throwable ex) {
- reader.getCursorBuffer().clearBuffer();
+ reader.getCursorBuffer().clear();
}
- reader.flushConsole();
+ reader.flush();
} else {
super.flush();
}