Paper
Paper copied to clipboard
Item stack name tooltip API
This adds an API for getting whether the current item stack that the player is holding is showing its name as a tooltip. It's important to note that this behavior can be configured via the accessbility settings, under notification time. This is still very useful for server owners, e.g. when you have a UI Overlay in your action bar, which is slightly shifted downwards using fonts, this can collide with the item's name tooltip. But instead, with this API, you can detect if it's shown and then raise the overlay a bit. Here is an example of this in action (not made by me):
https://github.com/PaperMC/Paper/assets/96977790/eaf40378-9e7f-494c-b96a-48596840c462
Welcome to paper 🎉 Thank you for your first PR!
Feel free to ask in the discord if you have any questions on the feedback! I like the concept of the PR otherwise.
As someone who does the things mentioned in the PR with the action bar, this is certainly very useful.
And it's clearly mentioned in the Javadocs that the server is limited in predicting it. Maintenance cost should be very low too.
However maybe just exposing itemStackChangeTime directly would make more sense? Then that value could also be used for other things (though I am not sure what those could be), without needing to keep track of it in the ItemHeldEvent
I feel like publishing both would make the most sense here as it's the best of both worlds
I think having isItemNameTooltipEstimatedToBeVisible is too unpredictable because of the already mentioned fact that it is entirely controller by the client and the server doesn't know the tooltip visibility at all
I would suggest only exposing the time in ticks like vanilla already has and plugins can use it like they want