Solved Interact Event Action

Discussion in 'Plugin Development' started by TheDiamond06, Jun 5, 2015.

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

    TheDiamond06

    I have this event that is registered and works:

    Code:java
    1. if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction().equals(Action.RIGHT_CLICK_BLOCK))
    2. {
    3. // code for testing which item. [Not showing]
    4. }
    5. else if(e.getAction() == Action.LEFT_CLICK_AIR || e.getAction().equals(Action.LEFT_CLICK_BLOCK))
    6. {
    7. // code for testing which item. [Not showing]
    8. }


    For some odd reason, the event only first when I am RIGHT/LEFT Clicking a block, not air. When I RIGHT/LEFT click the air, the continuing code does not happen. Why is it only firing the clicking the block and not the air? How would I fix this?
     
  2. Offline

    I Al Istannen

    @TheDiamond06 I don't know what the default value is, but have you tried changing the EventHandler annotation to "@EventHandler(ignoreCancelled = false)". This can be found here. Right click event in the air is automatically canceled.
     
  3. Offline

    TheDiamond06

    @I Al Istannen
    Code:java
    1.  
    2. @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
    3. public void actionClick(PlayerInteractEvent e)
    4. {
    5. if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction().equals(Action.RIGHT_CLICK_BLOCK))
    6. {//code}
    7. }

    already have done it before you said that and before I posted this question.
     
  4. Offline

    I Al Istannen

  5. Offline

    TheDiamond06

    @I Al Istannen How does that make sense?! It worked but how!? I thought ignoreCancelled set to true would make it so it ignores if the even is cancelled. How does settings it to false make it work.
     
  6. Offline

    I Al Istannen

    @TheDiamond06 Bukkit... You can read it up in the link I gave (here). Don't ask me why though.
     
Thread Status:
Not open for further replies.

Share This Page