Files
MinecraftChat/app/server/parsers/extra.js
T
AlexKvazos b9cab887f9 Core vanilla functionality
The client now understands chat events, command usage events, death events, teleport events, and join/leave events
2015-04-29 19:00:49 -05:00

30 lines
685 B
JavaScript

var stringToCode = require('../utils').stringToCode;
module.exports = function(extra) {
var string = '';
// for each piece of text
extra.forEach(function(data) {
// get the text out of the element
var text;
if (typeof data === 'string') {
text = data;
} else if (typeof data === 'object') {
text = data.text;
}
// if text is available
if (text) {
text = text.replace(/§k/ig, ''); // remove crazy format
text = text.replace(/§l/ig, ''); // remove bold format
string += '§' + stringToCode(data.color) + text; // add the color code to the string
}
});
return string;
};