Ability to differentiate between inventory sections.

    • Type: New Feature
    • Resolution: Fixed
    • Priority: Minor
    • None
    • Affects Version/s: None
    • Environment:

      *

    • *

      Example:
      A player has a chest open. A plugin needs to know whether the player clicks an item in their inventory or on the chest. Both items are in their equivalent inventory's slot 0. Currently there is no way, unless you know for absolutely certain that the two items are different or what they both are, to know which inventory the event occurred in. InventoryType will yield CHEST for both areas and the slot is identically numbered in both areas.

      This could be resolved through the introduction of a new API that itself reports which section of the inventory (For the example above, CombinedInventorySection.PLAYER would be an easily checked solution for problems like the example above).

          [SPIGOT-2527] Ability to differentiate between inventory sections.

          md_5 added a comment -

          InventoryView.getInventory
          InventoryClickEvent.getClickedInventory

          md_5 added a comment - InventoryView.getInventory InventoryClickEvent.getClickedInventory

          PixelPerfect added a comment -

          Good point, an alternative may be a couple enums to the earlier mentioned InventoryView and have it return that, then there could be 'OUTSIDE' 'REMOTE' 'LOCAL'.

          PixelPerfect added a comment - Good point, an alternative may be a couple enums to the earlier mentioned InventoryView and have it return that, then there could be 'OUTSIDE' 'REMOTE' 'LOCAL'.

          Black Hole added a comment -

          I think you'll need both methods since the slot number could be outside of both inventories.

          Black Hole added a comment - I think you'll need both methods since the slot number could be outside of both inventories.

          That would be an ideal way of doing it. Could even just be one method named something like isRemoteInventoryView(int remoteSlots, int rawSlot)

          PixelPerfect added a comment - That would be an ideal way of doing it. Could even just be one method named something like isRemoteInventoryView(int remoteSlots, int rawSlot)

          Black Hole added a comment - - edited

          So new methods InventoryView.isTopInventory(int rawSlot) and InventoryView.isBottomInventory(int rawSlot) could be useful.

          Black Hole added a comment - - edited So new methods InventoryView.isTopInventory(int rawSlot) and InventoryView.isBottomInventory(int rawSlot) could be useful.

          BillyGalbreath added a comment - - edited

          Get the rawslot number and compare it to the inventory size. Thats how you know which side of the inventory was clicked.

          http://paste.md-5.net/yibohakiwi.coffee

          BillyGalbreath added a comment - - edited Get the rawslot number and compare it to the inventory size. Thats how you know which side of the inventory was clicked. http://paste.md-5.net/yibohakiwi.coffee

          Hex added a comment -

          Re-opened as per reporter's request. Apparently the inventory view reported isn't actually helpful in this way.

          Hex added a comment - Re-opened as per reporter's request. Apparently the inventory view reported isn't actually helpful in this way.

          PixelPerfect added a comment - - edited

          InventoryView.OUTSIDE may be the solution, hard to tell what it does seeing as it has next to no documentation. Other than that, that leads back into InventoryType which is horribly broken and cannot be updated to keep the API backwards-compatible.

          EDIT: Following checking the source, I can confirm that OUTSIDE only defines -999 which is a reference to literally clicking outside of the inventory slots.

          PixelPerfect added a comment - - edited InventoryView.OUTSIDE may be the solution, hard to tell what it does seeing as it has next to no documentation. Other than that, that leads back into InventoryType which is horribly broken and cannot be updated to keep the API backwards-compatible. EDIT: Following checking the source, I can confirm that OUTSIDE only defines -999 which is a reference to literally clicking outside of the inventory slots.

          Black Hole added a comment -

          It's already there:
          Use InventoryEvent.getView()

          Black Hole added a comment - It's already there: Use InventoryEvent.getView()

            Assignee:
            Unassigned
            Reporter:
            PixelPerfect
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: