Merge pull request #98 from Strategetical/master

Use Bukkit's ChatColor class for more reliable output.
This commit is contained in:
Walter Higgins 2013-12-20 09:22:21 -08:00
commit 77e9d59e9b

View file

@ -3,30 +3,34 @@ String class extensions
----------------------- -----------------------
The following chat-formatting methods are added to the javascript String class.. The following chat-formatting methods are added to the javascript String class..
* black() * aqua()
* darkblue() * black()
* blue() * blue()
* darkgreen() * bold()
* darkaqua() * brightgreen()
* darkred() * darkaqua()
* purple() * darkblue()
* gold() * darkgray()
* gray() * darkgreen()
* darkgray() * purple()
* indigo() * darkpurple()
* brightgreen() * darkred()
* green() * gold()
* aqua() * gray()
* red() * green()
* pink() * italic()
* yellow() * lightpurple()
* white() * indigo()
* bold() * green()
* random() * red()
* strike() * pink()
* underline() * yellow()
* italic() * white()
* reset() * strike()
* random()
* magic()
* underline()
* reset()
Example Example
------- -------
@ -38,35 +42,40 @@ Example
***/ ***/
(function(){ (function(){
var c = org.bukkit.ChatColor;
var formattingCodes = { var formattingCodes = {
black: 0, aqua: c.AQUA,
darkblue: 1, black: c.BLACK,
blue: 1, blue: c.BLUE,
darkgreen: 2, bold: c.BOLD,
darkaqua: 3, brightgreen: c.GREEN,
darkred: 4, darkaqua: c.DARK_AQUA,
purple: 5, darkblue: c.DARK_BLUE,
gold: 6, darkgray: c.DARK_GRAY,
gray: 7, darkgreen: c.DARK_GREEN,
darkgray: 8, purple: c.LIGHT_PURPLE,
indigo: 9, darkpurple: c.DARK_PURPLE,
brightgreen: 'a', darkred: c.DARK_RED,
green: 'a', gold: c.GOLD,
aqua: 'b', gray: c.GRAY,
red: 'c', green: c.GREEN,
pink: 'd', italic: c.ITALIC,
yellow: 'e', lightpurple: c.LIGHT_PURPLE,
white: 'f', indigo: c.BLUE,
bold: 'l', green: c.GREEN,
random:'k', red: c.RED,
strike: 'm', pink: c.LIGHT_PURPLE,
underline: 'n', yellow: c.YELLOW,
italic: 'o', white: c.WHITE,
reset: 'r' strike: c.STRIKETHROUGH,
random: c.MAGIC,
magic: c.MAGIC,
underline: c.UNDERLINE,
reset: c.RESET
}; };
for (var method in formattingCodes){ for (var method in formattingCodes){
String.prototype[method] = function(m,c){ String.prototype[method] = function(c){
return function(){ return "§"+c + this;}; return function(){return c+this;};
}(method,formattingCodes[method]); }(formattingCodes[method]);
} }
}()); }());