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