You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Anvil inventories still don't work like they could #10352
So, there's been an ongoing issue with Bukkit and anvil inventories that seems to have persisted for quite some time. It's been rather frustrating, to say the least. Essentially, when attempting to create an anvil inventory using Bukkit's createInventory method, things just don't function as expected.
The crux of the problem lies in anvils created this way ending up as type CraftInventoryCustom instead of the expected CraftInventoryAnvil. This leads to a myriad of issues – events fail to trigger properly, and window properties appear to be behaving strangely. It's all quite bothersome.
Currently, the most dependable method to obtain a functional anvil is by utilizing Player#openAnvil. However, let's be honest, that's not a universal solution. There are instances where greater flexibility is required.
Describe the solution you'd like.
It would be incredibly helpful to have a method like Bukkit#createAnvil or perhaps a solution to address the issues in the existing createInventory methods.
Describe alternatives you've considered.
Currently, the way to go is by using NMS, which seems a bit silly for such a simple task.
However, let's be honest, that's not a universal solution. There are instances where greater flexibility is required.
Could you perhaps expand on the problems you have with this method?
I use that method to open a text input GUI and have no problems customizing the behavior with the different inventory events that are already in the Paper API
in some cases you want reusable inventories or custom inventory holders
also it is not possible to define a custom name for the inv when using player open anvil
Yeah, applying a custom name is currently very annoying, because you need to override the title in the InventoryOpenEvent, but I already opened a PR that alleviates this problem (#9658).
Iirc making the inventory reusable is not really possible, because the real inventory is tied to a player, but custom inventory holders would be indeed nice for easier handling of events
Activity
Sytm commentedon Mar 24, 2024
Could you perhaps expand on the problems you have with this method?
I use that method to open a text input GUI and have no problems customizing the behavior with the different inventory events that are already in the Paper API
NonSwag commentedon Mar 24, 2024
in some cases you want reusable inventories or custom inventory holders
also it is not possible to define a custom name for the inv when using player open anvil
Sytm commentedon Mar 24, 2024
Yeah, applying a custom name is currently very annoying, because you need to override the title in the InventoryOpenEvent, but I already opened a PR that alleviates this problem (#9658).
Iirc making the inventory reusable is not really possible, because the real inventory is tied to a player, but custom inventory holders would be indeed nice for easier handling of eventsNonSwag commentedon Mar 24, 2024
I think anvils are not player but location bound