AnvilGUI
AnvilGUI copied to clipboard
Title response?
It would be good if we can response with title of the GUI too.
What do you mean with response? The error messages?
What do you mean with response? The error messages?
I mean an alternative to AnvilGUI.Response.text("invalid number") that changes title of anvilGUI.
Definitely a feature that we should add. Perhaps requires a bit more thought than just adding a Response, because ideally a developer should be able to change the title and the text in a Response. Marking this as help wanted as I don't have time to implement it.
With the change to ResponseAction
s (#243), this is actually now very possible. Adding a ResponseAction.replaceTitle(String)
would require some implementation from the VersionWrapper side though, since titles are only supported in certain versions. Additionally, I am unsure if simply setting the inventory title in the NMS Container
will actually update it on the client - we may need to send additional packets for a title update.
With the change to
ResponseAction
s (#243), this is actually now very possible. Adding aResponseAction.replaceTitle(String)
would require some implementation from the VersionWrapper side though, since titles are only supported in certain versions. Additionally, I am unsure if simply setting the inventory title in the NMSContainer
will actually update it on the client - we may need to send additional packets for a title update.
Yes, to update the title you need to send the packet for opening the window again. Its problematic for this purpose since it will reset the anvil input to the name of the item in the left slot, so entirely discarding the user input.
To avoid this, the left item's display name needs to be updated to the previous anvil input, which can be obtained by using the PrepareAnvilEvent
which is the rename item packet.
But this will cause another problem, because both the anvil input and the left item's names are the same; resulting into an empty result slot. I've explained this in #232.
So either you don't care about having the user input cleared on a title update (for example if you just want to inform the user that the input is entirely wrong) or you do care (suggestions etc. coming up in the title as you type). The latter will always require the second slot filled with an enchantment book, I can't think of another way for preserving the user input and still having an item in the result slot while updating the title.
I think we should go with option 1 first, so just sending the window open packet again, and then see if it resolves this issue.