Solved Possible bug in creative InventoryClickEvent's slots

Discussion in 'Spigot Plugin Development' started by snowyCoder, May 25, 2017.

  1. If I print the event.getSlot() of an InventoryClickEvent when the player clicks the Hotbar (or quickbar, call it what you want) I get strange results, I do think that it's a bug, not sure though.
    So here's my problem:
    Normal Inventory: [36, 37, 38, 39, 40, 0, 1, 2, 3]
    Any other inventory: normal, first slot: 0, last: 8
    My version: Latest found (spigot-1.12-pre5)
    OS: Manjaro x64 + KDE
    Code:
    Code (Text):
    @EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
    protected void onPlayerClick(InventoryClickEvent e) {
        System.out.println(e.getSlotType().name() + ", raw:" + e.getRawSlot() + "->" + e.getSlot());
    }
    (+ Main)

    Am I stupid or is there a bug?
    [Edit] this bug appears only when the player is in Creative mode
     
    #1 snowyCoder, May 25, 2017
    Last edited: May 26, 2017
  2. ScarabCoder

    ScarabCoder Retired Resource Staff
    Retired

    I've noticed inventory slots in Spigot events are a bit strange. I used to use http://www.wiki.vg/Inventory for slot ID reference, but most of the time it doesn't apply.
     
  3. That page describes the raw slot, but getSlot should provide a slot that is relative to the tipe of inventory, so if I listen for the hotbar the numbers should always be from 0 to 8 (if I got it right, it's not properly documented)
     
  4. Update: I checked every inventory and the normal player's inventory is the only one that has this weird mutation (yeah, I don't know how to describe it) so I'm assuming this is a bug.
    I'm reporting it to JIRA
     
  5. It works normally for me, I just copied your code exactly.


    I've never had issues with it, maybe it's just your version.
     
  6. My error, it doesn't work only in creative
     
  7. Oh, aha. Make sure to mark this thread as 'solved'
     
  8. So it's confirmed that is a bug?
    Does it work from other spigot instances or is it only my problem?
    I don't think that I should make this thread solved without an answer
     
  9. can you use a other plugin in build patch and in the server other spigot ?
     
  10. @EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
    protected void onPlayerClick(InventoryClickEvent e) {
    System.out.println(e.getSlotType().name() + ", raw:" + e.getRawSlot() + "->" + e.getSlot());
    }//+ The rest of the listener, the main class for loading it and the plugin.yml file
     
  11. That's the code I used for testing (?)