Check if player puts an item on another item

Discussion in 'Spigot Plugin Development' started by Creepermanthe3rd, May 31, 2016.

  1. Hello, Im wondering how I could test for if a player puts an item on another item

    So, Im trying to find this out for my CustomEnchnat plugin. Here is an example of how this looks.

    https://gyazo.com/2b66a40e078ad3d006b608975b8100a7 BTW on Cosmic there is a change the book will destory your item or else it would have added a lore.

    All im wondering is how to detect if a player does that
    Thanks!
     
  2. This can be buggy.

    A good way to do this would be to use anvils.
     
  3. How could I do this? That is what i was going to do at first but could find a method for using anvils
     
  4. Use the InventoryClickEvent and check if the action is SWAP_WITH_CURSOR. Then, you can get the item on the cursor with #getCursor() and the item clicked with #getCurrentItem(). You can then do you checks and manipulate each item accordingly.

    Edit: keep in mind that this method doesn't seem to work for people in creative. Probably a bug with Spigot, but just remember.
     
    #7 xMrPoi, May 31, 2016
    Last edited: May 31, 2016
    • Like Like x 1