mirror of
https://github.com/tribufu/node-gamedig
synced 2026-06-01 09:42:41 +00:00
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:
parent
0b046f8721
commit
c5f8ec521d
2 changed files with 15 additions and 3 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
## To Be Released...
|
## To Be Released...
|
||||||
## 5.0.0
|
## 5.X.Y
|
||||||
* To be made...
|
* Fix the `name` field on Minecraft servers running Velocity with multiple layers of color encoding (#595)
|
||||||
|
|
||||||
## 5.1.0
|
## 5.1.0
|
||||||
* FOUNDRY - Added support (#585)
|
* FOUNDRY - Added support (#585)
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,19 @@ export default class minecraft extends Core {
|
||||||
name = description.text
|
name = description.text
|
||||||
}
|
}
|
||||||
if (!name && typeof description === 'object' && description.extra) {
|
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
|
state.name = name
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue