Solved How to stop this?

Discussion in 'Plugin Development' started by isleepzzz, Jan 12, 2015.

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

    isleepzzz

    Hey guys!
    I made my own plugin that will send potion affects to other people when you hit them.
    Inside the onEntityDamageByEntity:
    I do:
    Code:
    LivingEntity entity = (LivingEntity)event.getEntity();
    entity.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 60, power));
    
    However if they are in a NON-PVP area. (WorldGuard flag has pvp on 'deny') It will still send posion to them.
    How do I fix this? I'm not sure what to do :(
     
  2. @isleepzzz Alter the EventHandler annotation to listen on a higher priority and to ignore cancelled events.
     
    Konato_K likes this.
  3. Offline

    adam753

  4. Offline

    isleepzzz

    I actually did nothing on my priority. Then I changed it to the "lowest" because if my event got canceled (not in PvP area) then I want it to NOT send the potion effect.
    I don't see how setting it to "highest" would fix that?
     
  5. Offline

    Infuzion

    @isleepzzz
    A higher priority means you receive the event later. Check if another plugin of a lower priority canceled it:
    Code:
    if(!event.isCanceled){
    //Non-PvP area
    }else{
    //PvP area
    }
    and act accordingly.
    I would go with the Monitor Event Priority for this.
     
  6. Offline

    teej107

  7. Offline

    Infuzion

    @teej107
    As far as I know the OP does not want to modify the event, but listen to the outcome.
     
  8. Offline

    teej107

    @Infuzion He wants to change the outcome
    if the event is not cancelled.
     
  9. Offline

    isleepzzz

    Amazing! I had to set it to the highest.
    Thank you:)
     
Thread Status:
Not open for further replies.

Share This Page