Hotbar Click Event

Discussion in 'Spigot Plugin Development' started by ZevoGaems, May 3, 2017.

  1. I am trying to make a moderation hotbar like some HCF servers do and you can freeze the player and stuff like that I just need to know how would I detect if a player right clicks a item in the hotbar?
  2. You need to use the InventoryClickEvent and check if both slotType is equals to HOTBAR and clickType is equals to RIGHT
  3. konsolas


    This depends on what you mean by "right clicks an item in the hotbar"

    If you mean inside their inventory, then the event is InventoryClickEvent, in which you need to check if the slot number is in the hotbar.
    If you mean using an item by right clicking outside of the inventory, you should listen for PlayerInteractEvent and check e#getAction for RIGHT_CLICK_AIR or RIGHT_CLICK_BLOCK.
    • Agree Agree x 1
    • Informative Informative x 1
  4. Or if he mean when a player click a number/scroll for changing the item in the hand/mainhand, he should listen for PlayerHeldEvent

    EDIT: If you mean to listen for the PlayerInteractEvent and want to check if a player click air, you need to listen for the event even if it's cancelled (since it's fired as already cancelled)
  5. Ok thanks :D
    And I love your anticheat I use it <3