Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to parse Component from Json (packet) correctly #1286

Open
TheDevTec opened this issue Apr 7, 2024 · 1 comment
Open

Failed to parse Component from Json (packet) correctly #1286

TheDevTec opened this issue Apr 7, 2024 · 1 comment

Comments

@TheDevTec
Copy link

Hi, I ran into a problem when editing each player's displayName in tablist.

I found that the Component is not parsed correctly from the Packet that is sent from the Paper Spigot server (1.19.4 in my case), I have not tested other versions.
At first glance there is no problem, but once I get the Component (already corrupted - always without TextDecorations) and rewrite it back to the player's tablist, so you can see the problem at a glance
After a short search for the problem, I found that the json in the Packet has numbers in it instead of boolean for the TextDecorations values, so instead of "bold" being "true", it is "bold" with a value of "1" and in case of false, the value for the others is "0", the problem is that the parser that is in the code is not working as it should properly, see image.

Json from ComponentHolder:
{"extra":[{"color":"#00AAAA","underlined":0,"text":"L","bold":1,"strikethrough":0,"italic":0,"obfuscated":0},{"color":"#20BBBB","underlined":0,"text":"e","bold":1,"strikethrough":0,"italic":0,"obfuscated":0},{"color":"#40CCCC","underlined":0,"text":"a","bold":1,"strikethrough":0,"italic":0,"obfuscated":0},{"color":"#60DDDC","underlined":0,"text":"d","bold":1,"strikethrough":0,"italic":0,"obfuscated":0},{"color":"#80EEED","underlined":0,"text":"e","bold":1,"strikethrough":0,"italic":0,"obfuscated":0},{"color":"#A0FFFE","underlined":0,"text":"r","bold":1,"strikethrough":0,"italic":0,"obfuscated":0},{"color":"white","underlined":0,"text":" Straikerinos","bold":0,"strikethrough":0,"italic":0,"obfuscated":0}],"text":""}

Result after converting into Component:
TextComponentImpl{content="", style=StyleImpl{obfuscated=not_set, bold=not_set, strikethrough=not_set, underlined=not_set, italic=not_set, color=null, clickEvent=null, hoverEvent=null, insertion=null, font=null}, children=[TextComponentImpl{content="L", style=StyleImpl{obfuscated=false, bold=false, strikethrough=false, underlined=false, italic=false, color=NamedTextColor{name="dark_aqua", value="#00aaaa"}, clickEvent=null, hoverEvent=null, insertion=null, font=null}, children=[]}, TextComponentImpl{content="e", style=StyleImpl{obfuscated=false, bold=false, strikethrough=false, underlined=false, italic=false, color=TextColorImpl{value="#20bbbb"}, clickEvent=null, hoverEvent=null, insertion=null, font=null}, children=[]}, TextComponentImpl{content="a", style=StyleImpl{obfuscated=false, bold=false, strikethrough=false, underlined=false, italic=false, color=TextColorImpl{value="#40cccc"}, clickEvent=null, hoverEvent=null, insertion=null, font=null}, children=[]}, TextComponentImpl{content="d", style=StyleImpl{obfuscated=false, bold=false, strikethrough=false, underlined=false, italic=false, color=TextColorImpl{value="#60dddc"}, clickEvent=null, hoverEvent=null, insertion=null, font=null}, children=[]}, TextComponentImpl{content="e", style=StyleImpl{obfuscated=false, bold=false, strikethrough=false, underlined=false, italic=false, color=TextColorImpl{value="#80eeed"}, clickEvent=null, hoverEvent=null, insertion=null, font=null}, children=[]}, TextComponentImpl{content="r", style=StyleImpl{obfuscated=false, bold=false, strikethrough=false, underlined=false, italic=false, color=TextColorImpl{value="#a0fffe"}, clickEvent=null, hoverEvent=null, insertion=null, font=null}, children=[]}, TextComponentImpl{content=" Straikerinos", style=StyleImpl{obfuscated=false, bold=false, strikethrough=false, underlined=false, italic=false, color=NamedTextColor{name="white", value="#ffffff"}, clickEvent=null, hoverEvent=null, insertion=null, font=null}, children=[]}]}

https://i.imgur.com/T7BuxA7.png

  • Straikerinos
@electronicboy
Copy link
Member

I do not recall 1/0 being a valid value inside of that stuff, but, this is all generally passed by adventure, so if there is an issue with the deserialisation of stuff, it would probably be worth conveying that over there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants