Updated to reflect events rework.

This commit is contained in:
walterhiggins 2014-03-15 18:12:34 +00:00
parent f82d88cb3f
commit c3db7a4314

View file

@ -46,11 +46,11 @@ chosen color...
var colorCodes = {}; var colorCodes = {};
for (var i =0;i < colors.length;i++) colorCodes[colors[i]] = i.toString(16); for (var i =0;i < colors.length;i++) colorCodes[colors[i]] = i.toString(16);
events.on('player.AsyncPlayerChatEvent',function(l,e){ events.on( 'player.AsyncPlayerChatEvent', function( evt ) {
var player = e.player; var player = evt.player;
var playerChatColor = _store.players[ player.name ]; var playerChatColor = _store.players[ player.name ];
if ( playerChatColor ) { if ( playerChatColor ) {
e.message = '&sect;' + colorCodes[playerChatColor] + e.message; evt.message = '&sect;' + colorCodes[ playerChatColor ] + e.message;
} }
}); });
@ -95,7 +95,7 @@ players use to change their chat color setting. The full plugin source
code is just a couple of lines of code but is a fully working plugin... code is just a couple of lines of code but is a fully working plugin...
// declare a new javascript plugin // declare a new javascript plugin
var _store = {players: {}} // private variable var _store = { players: {} } ; // private variable
exports.chat = plugin('chat', { exports.chat = plugin('chat', {
setColor: function(player, color){ setColor: function(player, color){
_store.players[player.name] = color; _store.players[player.name] = color;
@ -108,13 +108,15 @@ code is just a couple of lines of code but is a fully working plugin...
'brightgreen', 'aqua', 'red', 'pink', 'brightgreen', 'aqua', 'red', 'pink',
'yellow', 'white']; 'yellow', 'white'];
var colorCodes = {}; var colorCodes = {};
for (var i =0;i < colors.length;i++) colorCodes[colors[i]] = i.toString(16); for ( var i =0; i < colors.length; i++ ) {
colorCodes[ colors[i] ] = i.toString(16);
}
events.on('player.AsyncPlayerChatEvent',function(l,e){ events.on( 'player.AsyncPlayerChatEvent', function( evt ) {
var player = e.player; var player = evt.player;
var playerChatColor = _store.players[player.name]; var playerChatColor = _store.players[player.name];
if ( playerChatColor ) { if ( playerChatColor ) {
e.message = '&sect;' + colorCodes[playerChatColor] + e.message; evt.message = '&sect;' + colorCodes[playerChatColor] + e.message;
} }
}); });
command( 'chat_color', function( params, sender ) { command( 'chat_color', function( params, sender ) {