Skip to content

Inventory Support on InventoryViewBuilders #12518

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Y2Kwastaken
Copy link
Contributor

The end goal of this pull request is to address the need to put Inventory on a view builder during the build process. The goal is to completely replace HumanEntity#openInvenotry(Inventory). and deprecate Bukkit#createInventory(InventoryType, ...); methods.

When deciding what approach to take to do this I decided it'd be best to avoid
A. Intrusive insertion of Inventories into builders. (This is because Inventories are supported on only some menus and not others)
B. Adding more inheritance (Adding more inheritance while allowing for a more streamlined builder process also makes implementation and future maintenance a pain).

In this iteration I took the approach to instead add an InventorySupport class that allows for the api consumer to cast their builder and then add the inventory from there.

final var builder = MenuType.GENERIC_9X2.builder();
if (builder instanceof InventorySupport<?> cast) {
    cast.inventory(this.container)
            .build(event.getPlayer())
             .open();
}
  • Add support for Inventories for applicable MenuType
  • Add new Bukkit#createMenuInventory or refactor Bukkit#createInventory method to allow for more arbitrarily sized containers
  • refactor opening logic to ensure "modern" inventories can not be opened outside of their use with InventoryViewBuilders

This is an early iterative draft I will take feedback and things may change a lot in between iterations based on feedback. I've opened it as I want feedback so I can continue to iterate on this API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Awaiting review
Development

Successfully merging this pull request may close these issues.

1 participant