Add UnsafeValues#deserializeItemHover
#13067
Open
+20
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds
UnsafeValues#deserializeItemHover
, to de-serialize an adventureShowItem
into anItemStack
.My use case for this is a custom component serializer implementation (similar idea to MiniMessage), that needs to get an
ItemStack
instance for its serialization logic (I'm aware there may be better methods to implement this, but the serializer already exists and is in use with Bungee chat, I'm just migrating it to adventure & need to maintain the exact same format and behavior).See discussion starting at https://discord.com/channels/289587909051416579/555462289851940864/1415331111856508980 (and specifically with lynx at https://discord.com/channels/289587909051416579/555462289851940864/1415336667237060650).
Note
This can throw some exceptions for invalid
ShowItem
data (e.g. usesRegistry#getOrThrow
), didn't really bother with that too much as it's anUnsafeValues
use at your own risk, but let me know if you'd want more specific docs still/to catch them and returnnull
.