From 3d637c4660c490d7538dd7ec023136fa2707f4cc Mon Sep 17 00:00:00 2001 From: CosminPerRam Date: Sun, 11 Aug 2024 14:30:53 +0300 Subject: [PATCH] feat: better minecraft name composure --- protocols/minecraft.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/protocols/minecraft.js b/protocols/minecraft.js index 7f9778fa..0f7d3633 100644 --- a/protocols/minecraft.js +++ b/protocols/minecraft.js @@ -60,22 +60,20 @@ export default class minecraft extends Core { const description = vanillaState.raw.description if (typeof description === 'string') { name = description - } - if (!name && typeof description === 'object' && description.text && description?.text?.trim()) { - name = description.text - } - if (!name && typeof description === 'object' && description.extra) { - let stack = [description]; + } else if (typeof description === 'object') { + name = description?.text || '' + + const stack = [description] while (stack.length) { - let current = stack.pop(); + const current = stack.pop() if (current.text) { - name += current.text; + name += current.text } if (Array.isArray(current.extra)) { - stack.push(...current.extra.reverse()); + stack.push(...current.extra.reverse()) } } }