Get all available keys in DialogResponseView#12814
Conversation
|
Can you use the adventure-nbt library? (Or any nbt library) and parse the BinaryTagHolder? I think that is the solution here for your specific usecase. |
I don't like to shade another library just to do this. Since there is already CompoundTag in DialogResponseView, why not a method to get all the keys from the compound? |
|
Because there is no guarantee that the value at that key can be parsed with any of the 3 get methods. I don't really want to expose keys that don't work with those methods. There is already no guarantee that the values that can be obtained via the 3 methods actually came from a dialog input. |
Since all getters in the View are Nullable, we don't really care about the guarantee. Even if we parse the inputs, we only care about the values that can be retrieved from the response. |
|
Interestingly, the response view already parses the payload to a compound tag, but we would need another NBT library to do the same without using reflections. |
|
I already used reflections to get the underlying compound of the response view so this is not a big deal for me. |
|
I agree with machine here, one major point of this interface was that it does not promise being authoritative in regards to its content. It is a minimal bare bone abstraction over what could be a dialog response for people to use. Any method promising to know what actual data is contained in it is just misleading imo. Thank you anyway for the PR! |
This PR adds a new method in DialogResponseView to get all available keys.
I don't know if there is any real-world usage with this, but in my case, I need a way to convert a response view to a simple String-Object map without reflection.