Skip to content
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

Fix and enhance openInventory(InventoryView) #11455

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

masmc05
Copy link
Contributor

@masmc05 masmc05 commented Sep 30, 2024

The new method allows overriding the title on the menu which is being opened without the necessity to listen to InventoryOpenEvent and setting InventoryOpenEvent#titleOverride(Component)

When creating this new api discovered an issue with the current method which has a very small fix, the issue being that currently when running

    @EventHandler
    public void onInventoryOpen(org.bukkit.event.inventory.InventoryOpenEvent event) {
        if (event.getInventory() instanceof HorseInventory) {
            event.getPlayer().getScheduler().runDelayed(this, task -> {
                event.getPlayer().openInventory(event.getPlayer().getOpenInventory());
            }, () -> {}, 40L);
        }
    }

You will get this error https://pastes.dev/yAFvj1yF6I

Should I instead of current behavior, pass the title override as the default value of InventoryOpenEvent#titleOverride?

@masmc05 masmc05 requested a review from a team as a code owner September 30, 2024 21:44
@Machine-Maker
Copy link
Member

You can already create views with any title via the MenuType API. Is there a point to adding this with the MenuType API already in?

@masmc05
Copy link
Contributor Author

masmc05 commented Oct 1, 2024

For current opened view, this method goes trough the proper whole open inventory process without closing it, maintaining the most similar state to the pre open state

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.

2 participants