Do what we can about Jline not being installed

This commit is contained in:
md_5 2013-06-17 17:05:02 +10:00
parent dbb6aebf58
commit 72f3a79759

View File

@ -36,6 +36,7 @@ import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import jline.UnsupportedTerminal;
import jline.console.ConsoleReader; import jline.console.ConsoleReader;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@ -63,6 +64,7 @@ import net.md_5.bungee.protocol.Vanilla;
import net.md_5.bungee.scheduler.BungeeThreadPool; import net.md_5.bungee.scheduler.BungeeThreadPool;
import net.md_5.bungee.tab.Custom; import net.md_5.bungee.tab.Custom;
import net.md_5.bungee.util.CaseInsensitiveMap; import net.md_5.bungee.util.CaseInsensitiveMap;
import org.fusesource.jansi.AnsiConsole;
/** /**
* Main BungeeCord proxy class. * Main BungeeCord proxy class.
@ -151,31 +153,18 @@ public class BungeeCord extends ProxyServer
public BungeeCord() throws IOException public BungeeCord() throws IOException
{ {
try AnsiConsole.systemInstall();
{ consoleReader = new ConsoleReader();
consoleReader = new ConsoleReader();
} catch ( Throwable t )
{
System.setProperty( "jline.terminal", "jline.UnsupportedTerminal" );
consoleReader = new ConsoleReader();
}
Runtime.getRuntime().addShutdownHook( new Thread( "JLine Cleanup Thread" )
{
@Override
public void run()
{
try
{
consoleReader.getTerminal().restore();
} catch ( Exception ex )
{
}
}
} );
logger = new BungeeLogger( this ); logger = new BungeeLogger( this );
System.setErr( new PrintStream( new LoggingOutputStream( logger, Level.SEVERE ), true ) ); System.setErr( new PrintStream( new LoggingOutputStream( logger, Level.SEVERE ), true ) );
System.setOut( new PrintStream( new LoggingOutputStream( logger, Level.INFO ), true ) ); System.setOut( new PrintStream( new LoggingOutputStream( logger, Level.INFO ), true ) );
if ( consoleReader.getTerminal() instanceof UnsupportedTerminal)
{
logger.info( "Unable to initialize fancy terminal. To fix this on Windows, install the correct Microsoft Visual C++ 2008 Runtime" );
logger.info( "NOTE: This error is non crucial, and BungeeCord will still function correctly! Do not bug the author about it unless you are still unable to get it working" );
}
} }
/** /**