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

Sometimes InventoryClickEvent.getCursor() do not work correctly

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • Icon: Minor Minor
    • None
    • None
    • Windows

      openjdk

       

    • 1.16.1-R0.1-latest
    • Yes

      If someone hold a item, then click quickly in solts. InventoryClickEvent.getCursor() will return a wrong result.

      Test Code

      @EventHandler
      public void onInventoryClick(InventoryClickEvent e) {
          Inventory inventory = e.getInventory();
          if (e.getRawSlot() < inventory.getSize()) {
      
              System.out.println(e.getCursor());
              if (e.getCursor() != null && e.getCursor().getType() == Material.DIRT) {
                  e.setCancelled(true);
              }
          }
      }
      

      Console:

      [23:34:03 INFO]: ItemStack{DIRT x 1}
      [23:34:03 INFO]: ItemStack{DIRT x 1}
      [23:34:03 INFO]: ItemStack{DIRT x 1}
      [23:34:04 INFO]: ItemStack{DIRT x 1}
      [23:34:04 INFO]: ItemStack{DIRT x 1}
      [23:34:04 INFO]: ItemStack{DIRT x 1}
      [23:34:04 INFO]: ItemStack{AIR x 0}
      

       

      Then the item was placed successfully in the solt

            Unassigned Unassigned
            Hanssc Hanssc
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: