Skip to content

Commit

Permalink
feat: better minecraft name composure
Browse files Browse the repository at this point in the history
  • Loading branch information
CosminPerRam committed Aug 11, 2024
1 parent 9448213 commit 3d637c4
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions protocols/minecraft.js
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}
}
Expand Down

0 comments on commit 3d637c4

Please sign in to comment.