InventoryDragEvent unable to change both cursor and content

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Minor
    • None
    • Affects Version/s: None
    • Environment:

      Craftbukkit/Spigot 1.8.R3
      git-Spigot-5f38d38-18fbb24 (MC: 1.8.8) (Implementing API version 1.8.8-R0.1-SNAPSHOT)

      In the description of InventoryDragEvent one can read:
      Any modifications to slots that are modified by the results of this InventoryDragEvent will be overwritten. To change these slots, this event should be cancelled and the changes applied.

      However, after cancelling the event you are unable to change the cursor contents.

      From Container.patch, line 78:

      if (event.getResult() != Result.DENY) {
          for (Map.Entry<Integer, ItemStack> dslot : draggedSlots.entrySet()) {
          view.setItem(dslot.getKey(), CraftItemStack.asBukkitCopy(dslot.getValue()));
          
          if (playerinventory.getCarried() != null) {
              playerinventory.setCarried(CraftItemStack.asNMSCopy(event.getCursor()));
              needsUpdate = true;
          }
      } else {
          playerinventory.setCarried(oldCursor);
      }
      

      There is no way to edit both the contents and cursor during the event execution. The event could set the cursor to event-changed value regardless of event result:

      if (event.getResult() != Result.DENY) {
          for (Map.Entry<Integer, ItemStack> dslot : draggedSlots.entrySet()) {
          view.setItem(dslot.getKey(), CraftItemStack.asBukkitCopy(dslot.getValue()));
      } else {
          playerinventory.setCarried(oldCursor);
      }
      
      if (playerinventory.getCarried() != null) {
          playerinventory.setCarried(CraftItemStack.asNMSCopy(event.getCursor()));
          needsUpdate = true;
      }
      

            Assignee:
            Unassigned
            Reporter:
            Noisy Cat
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: