Updated to reflect events rework.
This commit is contained in:
parent
f82d88cb3f
commit
c3db7a4314
1 changed files with 20 additions and 18 deletions
|
@ -46,11 +46,11 @@ chosen color...
|
|||
var colorCodes = {};
|
||||
for (var i =0;i < colors.length;i++) colorCodes[colors[i]] = i.toString(16);
|
||||
|
||||
events.on('player.AsyncPlayerChatEvent',function(l,e){
|
||||
var player = e.player;
|
||||
events.on( 'player.AsyncPlayerChatEvent', function( evt ) {
|
||||
var player = evt.player;
|
||||
var playerChatColor = _store.players[ player.name ];
|
||||
if ( playerChatColor ) {
|
||||
e.message = '§' + colorCodes[playerChatColor] + e.message;
|
||||
evt.message = '§' + 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...
|
||||
|
||||
// declare a new javascript plugin
|
||||
var _store = {players: {}} // private variable
|
||||
var _store = { players: {} } ; // private variable
|
||||
exports.chat = plugin('chat', {
|
||||
setColor: function(player, 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',
|
||||
'yellow', 'white'];
|
||||
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){
|
||||
var player = e.player;
|
||||
events.on( 'player.AsyncPlayerChatEvent', function( evt ) {
|
||||
var player = evt.player;
|
||||
var playerChatColor = _store.players[player.name];
|
||||
if ( playerChatColor ) {
|
||||
e.message = '§' + colorCodes[playerChatColor] + e.message;
|
||||
evt.message = '§' + colorCodes[playerChatColor] + e.message;
|
||||
}
|
||||
});
|
||||
command( 'chat_color', function( params, sender ) {
|
||||
|
|
Reference in a new issue