public final class Colors extends Object
This class contains constants that are useful for formatting lines sent to IRC servers. These constants allow you to apply various formatting to the lines, such as colours, boldness, underlining and reverse text.
The class contains static methods to remove colours and formatting from lines of IRC text.
Here are some examples of how to use the constants
message(Colors.BOLD + "A bold hello!"); A bold hello! message(Colors.RED + "Red" + Colors.NORMAL + " text"); Red text message(Colors.BOLD + "bold and " + Colors.RED + "," + Colors.BLUE + " red/blue"); or message(Colors.BOLD + "bold and " + Colors.bg(Colors.RED, Colors.BLUE) + " red/blue"); Bold and redPlease note that some IRC channels may be configured to reject any messages that use colours. Also note that older IRC clients may be unable to correctly display lines that contain colours and other control characters.
Note that this class name has been spelt in the American style in order to remain consistent with the rest of the Java API.
Forked and Maintained by Leon Blakey in PircBotX
Modifier and Type | Field and Description |
---|---|
static String |
BLACK
Black coloured text.
|
static String |
BLUE
Blue coloured text.
|
static String |
BOLD
Bold text.
|
static String |
BROWN
Brown coloured text.
|
static com.google.common.collect.ImmutableMap<String,String> |
COLORS_TABLE
Pre-built lookup table by String for all available colors
|
static String |
CYAN
Cyan coloured text.
|
static String |
DARK_BLUE
Dark blue coloured text.
|
static String |
DARK_GRAY
Dark gray coloured text.
|
static String |
DARK_GREEN
Dark green coloured text.
|
static com.google.common.collect.ImmutableMap<String,String> |
FORMATTING_TABLE
Pre-built lookup table by String for all available formatting options
|
static String |
GREEN
Green coloured text.
|
static String |
ITALICS
Italicized text.
|
static String |
LIGHT_GRAY
Light gray coloured text.
|
static com.google.common.collect.ImmutableMap<String,String> |
LOOKUP_TABLE
Pre-built lookup table by String for all the fields in this class.
|
static String |
MAGENTA
Magenta coloured text.
|
static String |
NORMAL
Removes all previously applied color and formatting attributes.
|
static String |
OLIVE
Olive coloured text.
|
static String |
PURPLE
Purple coloured text.
|
static String |
RED
Red coloured text.
|
static String |
REVERSE
Reversed text (may be rendered as italic text in some clients).
|
static String |
TEAL
Teal coloured text.
|
static String |
UNDERLINE
Underlined text.
|
static String |
WHITE
White coloured text.
|
static String |
YELLOW
Yellow coloured text.
|
Modifier and Type | Method and Description |
---|---|
static String |
bg(String foreground,
String background)
Set text and background color
|
static String |
lookup(String colorName)
Lookup color as a String
|
static String |
removeColors(String line)
Removes all colours from a line of IRC text.
|
static String |
removeFormatting(String line)
Remove formatting from a line of IRC text.
|
static String |
removeFormattingAndColors(String line)
Removes all formatting and colours from a line of IRC text.
|
static String |
set(String message,
String foregroundColor)
Sets the text color for a given message and appends
NORMAL |
static String |
set(String message,
String foregroundColor,
String backgroundColor)
Sets the text and background color for a given message and appends
NORMAL |
public static final String NORMAL
public static final String BOLD
public static final String UNDERLINE
public static final String REVERSE
public static final String WHITE
public static final String BLACK
public static final String DARK_BLUE
public static final String DARK_GREEN
public static final String RED
public static final String BROWN
public static final String PURPLE
public static final String OLIVE
public static final String YELLOW
public static final String GREEN
public static final String TEAL
public static final String CYAN
public static final String BLUE
public static final String MAGENTA
public static final String DARK_GRAY
public static final String LIGHT_GRAY
public static final String ITALICS
public static final com.google.common.collect.ImmutableMap<String,String> COLORS_TABLE
public static final com.google.common.collect.ImmutableMap<String,String> FORMATTING_TABLE
public static String lookup(String colorName)
colorName
- Name of field in this class, will be converted to
uppercasepublic static String bg(String foreground, String background)
foreground
- background
- public static String set(String message, String foregroundColor)
NORMAL
message
- foregroundColor
- public static String set(String message, String foregroundColor, String backgroundColor)
NORMAL
message
- foregroundColor
- public static String removeColors(String line)
line
- the input text.public static String removeFormatting(String line)
line
- the input text.Copyright © 2010–2020 Leon Blakey. All rights reserved.