• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

Using the Jansi library in your server console.

Joined
Apr 10, 2008
Messages
4,087
Reaction score
1,264
So, there's a cool library called Jansi, which allows your program to use Ansi Escape Sequences, even on Windows. That's a cool way to pump up your server, by coloring the console however you want - coloring exceptions and errors in the red color, information in blue, or whatever. This really helps rather than a console full of a wall of text of one color.

This is one of the results you can achieve (Taken from Jansi website), which is pretty awesome!:
Fraysa - Using the Jansi library in your server console. - RaGEZONE Forums


How to install the Jansi library into my project?
Simply download the Jansi library, located and add the .jar file into your dist folder. When you're about to compile your server, also add the jar to your referenced libraries - like you add the jars in the dist folder.

In your server's starting method, where ever it loads everything - place this line to load the Jansi Console.

Code:
AnsiConsole.systemInstall();

Now, you may also add the following fields at the top, for easier color indicating.

Code:
    public static final String BLACK = "\u001B[0;30m";
    public static final String RED = "\u001B[0;31m";
    public static final String GREEN = "\u001B[0;32m";
    public static final String YELLOW = "\u001B[0;33m";
    public static final String BLUE = "\u001B[0;34m";
    public static final String MAGENTA = "\u001B[0;35m";
    public static final String CYAN = "\u001B[0;36m";
    public static final String WHITE = "\u001B[0;37m";

How to use the colors, real time?

Here's a quick example, to print something in the red color.

Code:
AnsiConsole.out.println(RED + "Error loading MySQL Database!" + WHITE);

So, basically, what is done here?

Code:
AnsiConsole.out.println(COLOR_FOR_TEXT + "Text" + DEFAULT_CONSOLE_COLOR);

Self explainatory, pretty much, this will help you to see things better in my opinion rather than one color console.

Good luck~
 
Last edited:
Initiate Mage
Joined
Apr 19, 2014
Messages
1
Reaction score
0
Hey all, built a JANSI sample project to help new users to get up and running. Joined this forum to help spread the word: https:// github.com/ smaudet/jansi-sample
 
Last edited:
Back
Top