1.8.8 PlayerInteractEvent

Discussion in 'Spigot Plugin Development' started by DasChaos44, Mar 17, 2020.

  1. Hello,

    i write an PlayerInteractEvent, it works correctly but if i do left cilck also opens the Inventory.

    How can I make it, that only with a right cilck the inventory opens?
     
  2. Hello,

    I recommand you to read the javadoc: PlayerInteractEvent
    Sans titre.png
    You do not have to search too much, it's the first one....
     
    #2 Andross, Mar 17, 2020
    Last edited: Mar 18, 2020
  3. Code (Java):
    //on air
    if(event.getAction() == Action.RIGHT_CLICK_AIR) {
    //code
    }

    //on block
    if(event.getAction() == Action.RIGHT_CLICK_BLOCK) {
    //code
    }
     
  4. Strahan

    Benefactor

    Personally, I'd prefer to just return if the action is not the desired one. Saves some indentation.
     
  5. Saves a lot of indication if there is too much work logic and helps with debugging a lot!