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

Cancelling the PlayerDropItemEvent Causes Item Duplication from /give

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Minor Minor
    • None
    • None
    • None
    • Mac OS, Linux

    • git-Spigot-2040c4c-94cb030 (MC: 1.15.2) (Implementing API version 1.15.2-R0.1-SNAPSHOT)
    • Yes

      For what I assume are obscure Mojang reasons, the vanilla /give command is implemented by forcing the player to drop an item that they then immediately pick up (I think?)

      Unfortunately this causes some bad interaction with plugins that cancel drop events, as cancelling the drop event will cause the item to be given to the player, as well as the player getting the item (somehow?) anyway.

      Steps to reproduce:

      1. Install this test plugin: https://github.com/NathanWolf/Bukkit-Unit-Tests/releases/tag/DropCancel that will cancel the drop event for any diamond pickaxe
      2. Give yourself a diamond pickaxe using the vanilla /give command, "/give @p diamond_pickaxe"  
      3. Observer that you get two diamond pickaxes instead

      I tried to trace through this code myself but I got a little lost and can't figure out how the player is actually getting the item even if the drop event is cancelled. I was hoping to find a simple fix for this, but other than re-working the vanilla give command (which I assume is not an option, and definitely not a desirable option) I couldn't really see where to fix the problem.

      In my opinion, the bigger issue here is that the /give command is going to fire a drop event in a way a plugin probably doesn't expect, since the player is effectively dropping an item that they never had in their inventory in the first place. Maybe the event could be skipped somehow in this one case?

      Thanks for your time.

            Unassigned Unassigned
            NathanWolf Nathan Wolf
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: