Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-3363

Suggestion for an "Inventory Prepare Item Grid" event

    XMLWordPrintable

Details

    Description

      ISSUE

      Inventory-based GUIs are relatively common in plugins at the moment; the new 1.12 recipe book feature can cause issues with many implementations of these menus.

      While a plugin inventory GUI is open, if a player clicks the recipe book button, then selects a recipe in the recipe menu, all items from the plugin GUI will be returned to the player's inventory to allow the crafting grid to display the selected recipe. As far as I can tell, there is no way for plugin creators to prevent this using the current API.

      SUGGESTION

      A new event, InventoryPrepareCraftingGridEvent, is fired when the new PacketPlayInAutoRecipe is received by the server. The event extends InventoryEvent, implements Cancellable (cancellation causes the packet to be discarded), and contains the following methods:

      Player getPlayer();
      
      ItemStack[] getReturnedItems();
      
      ItemStack[] getPreviewItems();
      

      ~

      I think this could be a useful feature for a number of plugin makers, and would allow greater control over Inventories. Let me know if any clarification etc. is needed. Cheers!

      Attachments

        Activity

          People

            Unassigned Unassigned
            Fupery Fupery
            Votes:
            3 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated: