Update main/chatparser.js

This commit is contained in:
Yaode_owo 2024-10-12 09:27:44 -04:00
parent 130f4f4e62
commit cacadafd59

View file

@ -8,14 +8,23 @@ function uuidFromIntArray (arr) {
} }
function processNbtMessage(msg) { function processNbtMessage(msg) {
try { // RangeError: Maximum call stack size exceeded try {
if (!msg || msg.type === 'end' || msg === undefined) return undefined if (typeof msg === 'string') { // just create simple nbt structure
const simplified = nbt.simplify(msg) msg = {
const json = JSON.stringify(simplified, (key, val) => { id: 'string',
if (key === 'id' && Array.isArray(val)) return uuidFromIntArray(val) value: msg
return val };
}) }
return json
if (!msg || msg.type === 'end') return msg;
const simplified = nbt.simplify(msg); // Ensure nbt is defined elsewhere
const json = JSON.stringify(simplified, (key, val) => {
if (key === 'id' && Array.isArray(val)) return uuidFromIntArray(val);
return val;
});
return json;
} catch (e) { } catch (e) {
return '{"text":""}'; return '{"text":""}';
} }