Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
org.bukkit.ChatColor Enum Reference

Public Member Functions

char getChar ()
 
String toString ()
 
boolean isFormat ()
 
boolean isColor ()
 

Static Public Member Functions

static ChatColor getByChar (char code)
 
static ChatColor getByChar (String code)
 
static String stripColor (final String input)
 
static String translateAlternateColorCodes (char altColorChar, String textToTranslate)
 
static String getLastColors (String input)
 
 [static initializer]
 

Public Attributes

 BLACK =('0', 0x00)
 
 DARK_BLUE =('1', 0x1)
 
 DARK_GREEN =('2', 0x2)
 
 DARK_AQUA =('3', 0x3)
 
 DARK_RED =('4', 0x4)
 
 DARK_PURPLE =('5', 0x5)
 
 GOLD =('6', 0x6)
 
 GRAY =('7', 0x7)
 
 DARK_GRAY =('8', 0x8)
 
 BLUE =('9', 0x9)
 
 GREEN =('a', 0xA)
 
 AQUA =('b', 0xB)
 
 RED =('c', 0xC)
 
 LIGHT_PURPLE =('d', 0xD)
 
 YELLOW =('e', 0xE)
 
 WHITE =('f', 0xF)
 
 MAGIC =('k', 0x10, true)
 
 BOLD =('l', 0x11, true)
 
 STRIKETHROUGH =('m', 0x12, true)
 
 UNDERLINE =('n', 0x13, true)
 
 ITALIC =('o', 0x14, true)
 
 RESET =('r', 0x15)
 

Static Public Attributes

staticfinal char COLOR_CHAR = '\u00A7'
 

Detailed Description

All supported color values for chat

Definition at line 13 of file ChatColor.java.

Member Function Documentation

static ChatColor org.bukkit.ChatColor.getByChar ( char  code)
static

Gets the color represented by the specified color code

Parameters
codeCode to check
Returns
Associative org.bukkit.ChatColor with the given code, or null if it doesn't exist

Definition at line 163 of file ChatColor.java.

Referenced by org.bukkit.util.ChatPaginator.wordWrap().

163  {
164  return BY_CHAR.get(code);
165  }
static ChatColor org.bukkit.ChatColor.getByChar ( String  code)
static

Gets the color represented by the specified color code

Parameters
codeCode to check
Returns
Associative org.bukkit.ChatColor with the given code, or null if it doesn't exist

Definition at line 174 of file ChatColor.java.

174  {
175  Validate.notNull(code, "Code cannot be null");
176  Validate.isTrue(code.length() > 0, "Code must have at least one char");
177 
178  return BY_CHAR.get(code.charAt(0));
179  }
char org.bukkit.ChatColor.getChar ( )

Gets the char value associated with this color

Returns
A char value of this color code

Definition at line 133 of file ChatColor.java.

133  {
134  return code;
135  }
static String org.bukkit.ChatColor.getLastColors ( String  input)
static

Gets the ChatColors used at the end of the given input string.

Parameters
inputInput string to retrieve the colors from.
Returns
Any remaining ChatColors to pass onto the next line.

Definition at line 222 of file ChatColor.java.

References org.bukkit.ChatColor.isColor().

222  {
223  String result = "";
224  int length = input.length();
225 
226  // Search backwards from the end as it is faster
227  for (int index = length - 1; index > -1; index--) {
228  char section = input.charAt(index);
229  if (section == COLOR_CHAR && index < length - 1) {
230  char c = input.charAt(index + 1);
231  ChatColor color = getByChar(c);
232 
233  if (color != null) {
234  result = color.toString() + result;
235 
236  // Once we find a color or reset we can stop searching
237  if (color.isColor() || color.equals(RESET)) {
238  break;
239  }
240  }
241  }
242  }
243 
244  return result;
245  }
static ChatColor getByChar(char code)
Definition: ChatColor.java:163
staticfinal char COLOR_CHAR
Definition: ChatColor.java:107
boolean org.bukkit.ChatColor.isColor ( )

Checks if this code is a color code as opposed to a format code.

Definition at line 152 of file ChatColor.java.

Referenced by org.bukkit.ChatColor.getLastColors().

152  {
153  return !isFormat && this != RESET;
154  }
boolean org.bukkit.ChatColor.isFormat ( )

Checks if this code is a format code as opposed to a color code.

Definition at line 145 of file ChatColor.java.

145  {
146  return isFormat;
147  }
static String org.bukkit.ChatColor.stripColor ( final String  input)
static

Strips the given message of all color codes

Parameters
inputString to strip of color
Returns
A copy of the input string, without any coloring

Definition at line 187 of file ChatColor.java.

187  {
188  if (input == null) {
189  return null;
190  }
191 
192  return STRIP_COLOR_PATTERN.matcher(input).replaceAll("");
193  }
static String org.bukkit.ChatColor.translateAlternateColorCodes ( char  altColorChar,
String  textToTranslate 
)
static

Translates a string using an alternate color code character into a string that uses the internal ChatColor.COLOR_CODE color code character. The alternate color code character will only be replaced if it is immediately followed by 0-9, A-F, a-f, K-O, k-o, R or r.

Parameters
altColorCharThe alternate color code character to replace. Ex: &
textToTranslateText containing the alternate color code character.
Returns
Text containing the ChatColor.COLOR_CODE color code character.

Definition at line 205 of file ChatColor.java.

References org.bukkit.ChatColor.COLOR_CHAR.

205  {
206  char[] b = textToTranslate.toCharArray();
207  for (int i = 0; i < b.length - 1; i++) {
208  if (b[i] == altColorChar && "0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(b[i+1]) > -1) {
209  b[i] = ChatColor.COLOR_CHAR;
210  b[i+1] = Character.toLowerCase(b[i+1]);
211  }
212  }
213  return new String(b);
214  }

Member Data Documentation

org.bukkit.ChatColor.AQUA =('b', 0xB)

Represents aqua

Definition at line 61 of file ChatColor.java.

org.bukkit.ChatColor.BLACK =('0', 0x00)

Represents black

Definition at line 17 of file ChatColor.java.

org.bukkit.ChatColor.BLUE =('9', 0x9)

Represents blue

Definition at line 53 of file ChatColor.java.

org.bukkit.ChatColor.BOLD =('l', 0x11, true)

Makes the text bold.

Definition at line 85 of file ChatColor.java.

static final char org.bukkit.ChatColor.COLOR_CHAR = '\u00A7'
static

The special character which prefixes all chat colour codes. Use this if you need to dynamically convert colour codes from your custom format.

Definition at line 107 of file ChatColor.java.

Referenced by org.bukkit.ChatColor.translateAlternateColorCodes(), and org.bukkit.util.ChatPaginator.wordWrap().

org.bukkit.ChatColor.DARK_AQUA =('3', 0x3)

Represents dark blue (aqua)

Definition at line 29 of file ChatColor.java.

org.bukkit.ChatColor.DARK_BLUE =('1', 0x1)

Represents dark blue

Definition at line 21 of file ChatColor.java.

org.bukkit.ChatColor.DARK_GRAY =('8', 0x8)

Represents dark gray

Definition at line 49 of file ChatColor.java.

org.bukkit.ChatColor.DARK_GREEN =('2', 0x2)

Represents dark green

Definition at line 25 of file ChatColor.java.

org.bukkit.ChatColor.DARK_PURPLE =('5', 0x5)

Represents dark purple

Definition at line 37 of file ChatColor.java.

org.bukkit.ChatColor.DARK_RED =('4', 0x4)

Represents dark red

Definition at line 33 of file ChatColor.java.

org.bukkit.ChatColor.GOLD =('6', 0x6)

Represents gold

Definition at line 41 of file ChatColor.java.

Referenced by org.bukkit.help.IndexHelpTopic.buildIndexLine().

org.bukkit.ChatColor.GRAY =('7', 0x7)

Represents gray

Definition at line 45 of file ChatColor.java.

Referenced by org.bukkit.help.IndexHelpTopic.buildPreamble().

org.bukkit.ChatColor.GREEN =('a', 0xA)

Represents green

Definition at line 57 of file ChatColor.java.

org.bukkit.ChatColor.ITALIC =('o', 0x14, true)

Makes the text italic.

Definition at line 97 of file ChatColor.java.

org.bukkit.ChatColor.LIGHT_PURPLE =('d', 0xD)

Represents light purple

Definition at line 69 of file ChatColor.java.

org.bukkit.ChatColor.MAGIC =('k', 0x10, true)

Represents magical characters that change around randomly

Definition at line 81 of file ChatColor.java.

org.bukkit.ChatColor.RED =('c', 0xC)
org.bukkit.ChatColor.RESET =('r', 0x15)

Resets all previous chat colors or formats.

Definition at line 101 of file ChatColor.java.

org.bukkit.ChatColor.STRIKETHROUGH =('m', 0x12, true)

Makes a line appear through the text.

Definition at line 89 of file ChatColor.java.

org.bukkit.ChatColor.UNDERLINE =('n', 0x13, true)

Makes the text appear underlined.

Definition at line 93 of file ChatColor.java.

org.bukkit.ChatColor.WHITE =('f', 0xF)

Represents white

Definition at line 77 of file ChatColor.java.

Referenced by org.bukkit.help.IndexHelpTopic.buildIndexLine(), and org.bukkit.util.ChatPaginator.wordWrap().

org.bukkit.ChatColor.YELLOW =('e', 0xE)

Represents yellow

Definition at line 73 of file ChatColor.java.


The documentation for this enum was generated from the following file: