Slot Type in InventoryDragEvent

Discussion in 'Plugin Development' started by Badeye, Feb 17, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Badeye

    Hey, i realy need to know how i can get the SlotType of a slot during a InventoryDragEvent.
    e.getSlotType() does not work, but that is quite obvious since the drag event registers a number of slots at the same time.

    I have managed to get the string of slots used and split it into numbers. Now i have a for loop and each time it checks each slot number. Now i need to know the SlotType of those slots (if it is a quickbar or container or armor slot, i do not need the InventoryType, since that is only giving me "crafting" for example. I need to clearify between quickbar and the rest, which works very well in the InventoryClickEvent).

    Thanks, badeye
     
    AnorZaken likes this.
  2. Offline

    desht

    A quick look at the Bukkit/CraftBukkit source suggests the only way to do this is via direct access to the OBC CraftInventoryView class, e.g.:

    PHP:
    SlotType st CraftInventoryView.getSlotType(event.getView());
    Sadly, this method is not part of the Bukkit API, so you'll be dealing with CraftBukkit versioning here, or messing with reflection.
     
    AnorZaken likes this.
  3. Offline

    AnorZaken

    *Resurrection*
    Sorry for reviving but I needed this as well, and I don't want to deal with CraftBukkit versioning for compatibility and I don't want reflection for performance. Happily there is a very simple solution I want to share:

    The CraftInventoryView.getSlotType code is implemented with only Bukkit-API methods! :D
    (Thus it surely has my vote for being added to the API! It's highly useful!)
     
Thread Status:
Not open for further replies.

Share This Page