Multiple events triggering at the same time.

Discussion in 'Plugin Development' started by belven000, Feb 6, 2014.

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

    belven000

    I've been doing some bug fixing for my healer class and came across players being healed 2x every click. Looking into it I established that both PlayerInteractEvent and PlayerInteractEntityEvent run at the same time.

    Code:java
    1.  
    2. @EventHandler
    3. public void onPlayerInteractEntityEvent(PlayerInteractEntityEvent event)
    4. {
    5. PerformClassAbility(event);
    6. }
    7.  
    8. @EventHandler
    9. public void onPlayerInteractEvent(PlayerInteractEvent event)
    10. {
    11. PerformClassAbility(event);
    12. }
    13.  


    However I believed that by doing if (event.getAction() == Action.RIGHT_CLICK_AIR) in this:

    Code:java
    1.  
    2. public void PerformClassAbility(PlayerInteractEvent event)
    3. {
    4. if (event.getAction() == Action.RIGHT_CLICK_AIR)
    5. {
    6. Player currentPlayer = event.getPlayer();
    7.  
    8. StringToClass(plugin.CurrentClasses.get(currentPlayer),
    9. currentPlayer);
    10. }
    11. }
    12.  


    I would only run the event if they had no entity involved. Is there another way to do this?
     
  2. Offline

    Weasel_Squeezer

    why are you doing the same action on both events? why not stick to one of them?
     
  3. Offline

    belven000

    Ok so I have a heal and bandage ability on my healer. The healer is with the tank and right clicks him/her and gives them a bandage (4 hearts of absorption). The healer gets hit from behind and takes a fair amount of damage. The healer then needs to self heal. If the healer is looking at anything but a block or player they will heal themselves.

    Another example is the mage, you don't want to cast if you're looking at a friendly player so I need to know if they are interacting (right click to cast) with anything bu a player to cast.
     
Thread Status:
Not open for further replies.

Share This Page