fix: minecraft velocity name with multiple layers of color encoding (#595)

* fix: minecraft velocity recursive name

* chore: update CHANGELOG.md

* feat: remove obvious (?) condition

* feat: simplify using javascript code moment
This commit is contained in:
CosminPerRam 2024-07-29 13:52:12 +03:00 committed by GitHub
parent 0b046f8721
commit c5f8ec521d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 3 deletions

View file

@ -1,7 +1,7 @@
## To Be Released...
## 5.0.0
* To be made...
## 5.X.Y
* Fix the `name` field on Minecraft servers running Velocity with multiple layers of color encoding (#595)
## 5.1.0
* FOUNDRY - Added support (#585)

View file

@ -65,7 +65,19 @@ export default class minecraft extends Core {
name = description.text
}
if (!name && typeof description === 'object' && description.extra) {
name = description.extra.map(part => part.text).join('')
let stack = [description];
while (stack.length) {
let current = stack.pop();
if (current.text) {
name += current.text;
}
if (Array.isArray(current.extra)) {
stack.push(...current.extra.reverse());
}
}
}
state.name = name
} catch (e) {}