Paper icon indicating copy to clipboard operation
Paper copied to clipboard

Fix and enhance openInventory(InventoryView)

Open masmc05 opened this issue 1 year ago • 3 comments

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 avatar Sep 30 '24 21:09 masmc05

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?

Machine-Maker avatar Oct 01 '24 02:10 Machine-Maker

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

masmc05 avatar Oct 01 '24 09:10 masmc05

Rebased on 1.21.3

masmc05 avatar Nov 24 '24 13:11 masmc05