Refactor EffOpenInventory to support the newer MenuType api by paper#8384
Refactor EffOpenInventory to support the newer MenuType api by paper#8384sovdeeth merged 27 commits intoSkriptLang:dev/patchfrom
Conversation
… backwards compatiblity. Tested Versions: - 1.20.4 (skript didn't enable because of a different syntax element, unsupported) - 1.21.1 - 1.21.3 - 1.21.4 - 1.21.10 - 1.21.11
… and add new description of the @SInCE added in this PR. Refactoring EffOpenInventory to avoid a bug on 1.21.1 where creating an InventoryView with a null title is not possible (paper fixed this in 1.21.3)
There was a problem hiding this comment.
Pull request overview
This PR refactors the EffOpenInventory class to support Paper's newer MenuType API (introduced in 1.21.1, improved in 1.21.4) while maintaining backwards compatibility with the legacy Bukkit API. This fixes issues with anvil text input and enchanting/anvil functionality on Minecraft 1.21.4+.
Changes:
- Adds MenuType API support with fallback to Bukkit's createInventory for older versions
- Refactors the init and execute methods for better code organization and clarity
- Updates documentation annotations from @example to @examples
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com>
Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com>
…openInventoryType is called.
…g and related bug fixes
…ory, remove static declaration for openInventoryType(Player player, InventoryType type)
Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com>
Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com>
Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com>
…to a single pattern supporting both 'inventory' and 'inventorytype'
| {"close (%players%'[s] inventory [view]|[the] inventory [view] (to|of|for) %players%)", null}, | ||
| {"open %inventory/inventorytype% (to|for) %players%", null}, | ||
| {"open [a] (crafting table|workbench) (to|for) %players%", InventoryType.WORKBENCH}, | ||
| {"open [a] chest (to|for) %players%", InventoryType.CHEST}, | ||
| {"open [a[n]] anvil (to|for) %players%", InventoryType.ANVIL}, | ||
| {"open [a] hopper (to|for) %players%", InventoryType.HOPPER}, | ||
| {"open [a] dropper (to|for) %players%", InventoryType.DROPPER}, | ||
| {"open [a] dispenser (to|for) %players%", InventoryType.DISPENSER} |
There was a problem hiding this comment.
might consider putting the first two patterns at the end, instead, since they are more expensive to parse than the others. optional
There was a problem hiding this comment.
Oh? Does the parser parse in order of me registering them?
There was a problem hiding this comment.
Yes, it will try the patterns in order when attempting a syntaxinfo
Refactor EffOpenInventory to support the newer MenuType api by paper, included some backwards compatiblity.
Tested Versions:
Problem
The legacy Bukkit api has been lacking functionality for a while also this class is currently a pretty big mess.
Solution
Adding support for the newer paper api introduced in
1.21.1, older versions fallback on the Bukkit apiTesting Completed
command inventory: trigger: set {_r} to random element of integers between 1 and 5 if {_r} is 1: open crafting table to player else if {_r} is 2: open chest to player else if {_r} is 3: open anvil to player else if {_r} is 4: open dropper to player else if {_r} is 5: open dispenser to player send {_r} to playerSupporting Information
This fixes Anvil text input Issue and Enchanting and Anvil not working issue on
1.21.4+.While the actual api was added in 1.21.1, it was only improved to support nullable titles in 1.21.4.
Completes: #6954 #6470
Related: Issues listed in Supporting Information
AI assistance: no ai was used