Skip to content

Commit

Permalink
fix: minecraft velocity name with multiple layers of color encoding (#…
Browse files Browse the repository at this point in the history
…595)

* fix: minecraft velocity recursive name

* chore: update CHANGELOG.md

* feat: remove obvious (?) condition

* feat: simplify using javascript code moment
  • Loading branch information
CosminPerRam authored Jul 29, 2024
1 parent 0b046f8 commit c5f8ec5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
14 changes: 13 additions & 1 deletion protocols/minecraft.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Expand Down

0 comments on commit c5f8ec5

Please sign in to comment.