2024-07-30 05:56:23 -04:00
|
|
|
const { processNbtMessage } = require('prismarine-chat')
|
|
|
|
const parse = function (data) {
|
|
|
|
if (typeof data.type === 'string') {
|
|
|
|
return JSON.parse(processNbtMessage(data))
|
|
|
|
} else if (typeof data === 'string') {
|
|
|
|
return JSON.parse(data)
|
|
|
|
} else {
|
|
|
|
return data
|
|
|
|
}
|
|
|
|
}
|
2024-07-30 15:40:28 -04:00
|
|
|
const parse2 = function (_data) {
|
|
|
|
try {
|
|
|
|
return parse(_data)
|
|
|
|
} catch (e) {
|
|
|
|
console.error(e)
|
|
|
|
return {
|
|
|
|
text: 'An error occured while parsing a message. See console for more information.'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-07-31 01:08:25 -04:00
|
|
|
module.exports = parse2
|