Counting real damage

Discussion in 'Plugin Development' started by stirante, Jan 19, 2014.

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

    stirante

    Hey!
    I added to one of my plugins ability to count damage dealt and taken, but if player spams attack, this fake damage is also counted. How to fix it?
    Here is pseud-code (actual code won't tell you anything) :
    Code:
      @EventHandler(ignoreCancelled = true)
      public void onDamage(EntityDamageByEntityEvent e) {
          if (its non-pvp region stuff) return;
          if (e.getDamager() instanceof Projectile && ((Projectile) e.getDamager()).getShooter() instanceof Player) {
              Double dmg = loading dmg dealt from shooter;
              dmg = dmg + e.getDamage();
              setting new dmg dealt;
          }
          else if (e.getDamager() instanceof Player) {
              Double dmg = loading dmg dealt;
              dmg = dmg + e.getDamage();
              setting new dmg dealt;
          }
      }
     
  2. Offline

    Chinwe

    I found that checking this seems to get round it :)
    Code:
    if (damagedEntity.getNoDamageTicks() > 10) return;
    By the way, there's no need to give pseudo-code instead of your actual, noone is going to steal it :rolleyes:
     
    stirante likes this.
  3. Offline

    stirante

    I just realised that there is no method getNoDamageTicks()
    By the way, i used pseudo-code becouse actual code won't help, these are only simple getters and setters from my database.
     
  4. Offline

    xTigerRebornx

    stirante likes this.
  5. Offline

    stirante

Thread Status:
Not open for further replies.

Share This Page