Velocity icon indicating copy to clipboard operation
Velocity copied to clipboard

Failed to parse Component from Json (packet) correctly

Open TheDevTec opened this issue 1 year ago • 2 comments

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

TheDevTec avatar Apr 07 '24 19:04 TheDevTec

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

electronicboy avatar Apr 08 '24 08:04 electronicboy

this is the cause of PaperMC/Paper#11054 being re-opened. root cause is either adventure returning false for the style, when set to 1 in json, or velocities nbt parse shouldnt be returning "1" for bytes (instead emitting json bools)

456dev avatar Sep 09 '24 03:09 456dev