KyoriPowered / adventure

A user-interface library, formerly known as text, for Minecraft: Java Edition
https://docs.advntr.dev/
MIT License
678 stars 103 forks source link

show_item client safety #1086

Closed rwnd-bradley closed 3 days ago

rwnd-bradley commented 3 days ago

minecraft:air is not supported in show_item for 1.21+ clients and will crash if received:

Caused by: io.netty.handler.codec.DecoderException: Failed to decode: Failed to parse either. First: Failed to parse either. First: Item must not be minecraft:air; Second: Not a string; Second: No key value in MapLike[{action:"show_item",contents:{count:0L,id:"minecraft:air"}}] {color:"gray",extra:[{"":"PlayerName"},{"":": "},{extra:[{color:"white",hoverEvent:{action:"show_item",contents:{count:0L,id:"minecraft:air"}},translate:"chat.square_brackets",with:[{extra:[{translate:"block.minecraft.air"}],text:""}]},{"":" message"}],text:""}],text:""}

I'm not sure about Adventure's stance on this sort of validation. Should the implementation source be responsible for this instead (i.e., Paper)?

ref: HoverEventSource#asHoverEvent and possibly adventure's serializers

kezz commented 3 days ago

This isn't something Adventure would handle and should be up to the implementations to prevent this from being sent to clients.