Damage Events

Discussion in 'Plugin Development' started by Hex_27, Aug 7, 2015.

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

    Hex_27

    So for example, if I had this event:
    Code:
    @EventHandler
    public void onAttack(EntityDamageEvent event){
    
    event.setDamage(5.0);
    
    }
    
    @EventHandler
    public void onAttackTwo(EntityDamageEvent event){
    
    event.setDamage(event.getDamage() + 2);
    
    }
    Will event.getDamage() in onAttackTwo be 5, or be the original damage amount?
     
  2. Try it out :D But I think onAttackTwo gets called after onAttack. And why do you have 2 same events?
     
  3. Offline

    Boomer

    It would likely be the original value. It may be either value though, and that may be either value depending on if the clock on the cpu is odd or even. Unless you prioritize one to be lower priority in order to happen before the other, equal priorities of events will be handled at random between plugins and within plugins.

    You shouldn't have two methods for the same event esp if they depend on each other, although there are justifiable reasons for having two different blocks of code happen during the same event when you do need to respond both with lowest priority for one aspect of event information, and simultaneously with highest prioirity once the other plugins have had a chance at the event
     
  4. Offline

    Hex_27

    @FisheyLP @Boomer
    No it's not that, I have 5 different classes handling 5 different things using the same type of event.
     
  5. Offline

    Boomer

    then it still comes down to if you need one to run before the other, use different priority levels to assure one will happen before the others of a different priority level, but once again, once two events are at the same priority level, they go in the pool with all the other plugins with events at that priority level, and the order the code runs in is drawn out of a hat for that priority level. Totally uncontrollable which plugin gets it first, which class gets it first, within a given priority level, but, controllable which gets it before others for different levels.
     
  6. Offline

    Hex_27

    @Boomer
    I looked at the event priorities in the wiki, but I'm a little confused by which comes first. Is it possible for you to list which comes first for the the highest priority, lowest priority and moniter?
     
  7. Offline

    SuperOriginal

    Lowest is called first
    Monitor is called last (monitor should not modify the event, just monitor it - hence the name.)
     
Thread Status:
Not open for further replies.

Share This Page