Solved EDBEEvent firing without player damaged?

Discussion in 'Plugin Development' started by MordorKing78, Jan 31, 2015.

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

    MordorKing78

    So, This is a huge problem on my server. Becuz I have swords that do extra "stuff" in the server.
    I use WorldGuard to protect zones from players pvping. But those swords with extra "stuff" just do the effects in those areas. So how do I detect if a player is REALLY getting damaged?

    FIX:
    Code:
    @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
     
    Last edited: Feb 2, 2015
  2. Offline

    Fuzzybear04

    EntityDamageEvent?
     
  3. Offline

    drpk

    @MordorKing78 check if the event isn't cancelled or hook into the worldguard api and check if they are in a pvp zone.
     
  4. Offline

    MordorKing78

  5. Offline

    Fuzzybear04

    You can get DamageCause though can't you?
     
  6. Offline

    MordorKing78

    Bayuump!

    @Fuzzybear04 Won't work.

    <Edited by bwfcwalshy: Merged posts, please use the edit button rather than double posting.>
     
    Last edited by a moderator: Feb 2, 2015
  7. Offline

    Fuzzybear04

    @MordorKing78 does the worldguard api not have anything to do with it?
     
  8. Offline

    1Rogue

    It helps to show your current code.
     
  9. Offline

    Hawktasard

    @MordorKing78
    Might be a shitty solution, But you should be able to change the events priority and check if it has been cancelled or the damage is less than 1.
     
  10. Offline

    MordorKing78

    @Hawktasard Could you explain it a little bit? I check if the damage is less but the even still thinks the player is damaged.

    @Fuzzybear04 Never worked with the API before.

    @1Rogue Well, Some code:
    Code:
        @EventHandler
        public void onEntityDamage(EntityDamageByEntityEvent event) {
                Player damaged = (Player) event.getEntity();
                Player damager = (Player) event.getDamager();
                           
                //ITEMS
                String helmet = damaged.getInventory().getHelmet().getItemMeta().getDisplayName();
                String chestplate = damaged.getInventory().getChestplate().getItemMeta().getDisplayName();
                String leggings = damaged.getInventory().getLeggings().getItemMeta().getDisplayName();
                String boots = damaged.getInventory().getBoots().getItemMeta().getDisplayName();
    
                //STUFF HAPENS
        }
    I removed all the code in it with effects..
     
  11. Offline

    1Rogue

    This tells me nothing other than you cast without checking the types. You should include the full method (including annotations on the method signature)
     
  12. Offline

    MordorKing78

    @1Rogue I have no code becuz im qlueless.. I just want this problem to be solved and I was wondering if someone knows how.
     
  13. Offline

    1Rogue

    Just because worldguard cancels the damage doesn't mean the event won't fire. You can simply apply the effects in your event and specify to not show effects if the event is cancelled via the EventHandler:

    Code:java
    1. @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) //use HIGHEST if you are changing outcome
    2. public void onHit(EntityDamageByEntityEvent event) { //...
     
    MordorKing78 likes this.
  14. Offline

    MordorKing78

    @1Rogue Thanks this works correctly! Didn't know about ignoreCancelled!
     
Thread Status:
Not open for further replies.

Share This Page