Merge pull request #98 from Strategetical/master
Use Bukkit's ChatColor class for more reliable output.
This commit is contained in:
commit
77e9d59e9b
1 changed files with 60 additions and 51 deletions
|
@ -3,29 +3,33 @@ 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..
|
||||||
|
|
||||||
|
* aqua()
|
||||||
* black()
|
* black()
|
||||||
* darkblue()
|
|
||||||
* blue()
|
* blue()
|
||||||
* darkgreen()
|
* bold()
|
||||||
|
* brightgreen()
|
||||||
* darkaqua()
|
* darkaqua()
|
||||||
* darkred()
|
* darkblue()
|
||||||
|
* darkgray()
|
||||||
|
* darkgreen()
|
||||||
* purple()
|
* purple()
|
||||||
|
* darkpurple()
|
||||||
|
* darkred()
|
||||||
* gold()
|
* gold()
|
||||||
* gray()
|
* gray()
|
||||||
* darkgray()
|
|
||||||
* indigo()
|
|
||||||
* brightgreen()
|
|
||||||
* green()
|
* green()
|
||||||
* aqua()
|
* italic()
|
||||||
|
* lightpurple()
|
||||||
|
* indigo()
|
||||||
|
* green()
|
||||||
* red()
|
* red()
|
||||||
* pink()
|
* pink()
|
||||||
* yellow()
|
* yellow()
|
||||||
* white()
|
* white()
|
||||||
* bold()
|
|
||||||
* random()
|
|
||||||
* strike()
|
* strike()
|
||||||
|
* random()
|
||||||
|
* magic()
|
||||||
* underline()
|
* underline()
|
||||||
* italic()
|
|
||||||
* reset()
|
* 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]);
|
||||||
}
|
}
|
||||||
}());
|
}());
|
||||||
|
|
Reference in a new issue