Program: 187701
Project: 187701
Buggy source:
public void onEntityDamage(EntityDamageEvent event){
  if (event.getEntity() instanceof Wolf) {
    if (!(event instanceof EntityDamageByEntityEvent)) {
      return;
    }
    EntityDamageByEntityEvent e=(EntityDamageByEntityEvent)event;
    if (e.getDamager() instanceof Player) {
      Player player=(Player)e.getDamager();
      if (event.isCancelled() == false) {
        if (ConfigBuffer.mWolves.containsKey(player.getName()) == false) {
          if (MyWolfPermissions.has(player,"String_Node_Str") == false || player.getItemInHand().getType() != MyWolfConfig.LeashItem) {
            return;
          }
          Wolf TargetWolf=(Wolf)event.getEntity();
          String OwnerOfTheWolf=((CraftWolf)TargetWolf).getHandle().getOwnerName();
          Player Attacker=(Player)e.getDamager();
          boolean isTarmed=TargetWolf.isTamed();
          if (isTarmed == true && OwnerOfTheWolf.equals(Attacker.getName())) {
            event.setCancelled(true);
            ConfigBuffer.mWolves.put(player.getName(),new Wolves(player.getName()));
            ConfigBuffer.mWolves.get(player.getName()).createWolf((Wolf)event.getEntity());
            MyWolf.Plugin.SaveWolves(ConfigBuffer.WolvesConfig);
            player.sendMessage(MyWolfUtil.SetColors(MyWolfLanguage.getString("String_Node_Str")));
          }
        }
        String WolfOwner=null;
        for (        String owner : ConfigBuffer.mWolves.keySet()) {
          if (ConfigBuffer.mWolves.get(owner).getID() == event.getEntity().getEntityId()) {
            WolfOwner=owner;
            break;
          }
        }
        if (WolfOwner != null && WolfOwner.equals(player.getName())) {
          Wolves wolf=ConfigBuffer.mWolves.get(WolfOwner);
          wolf.ResetSitTimer();
          wolf.SetName();
          if (player.getItemInHand().getType() == MyWolfConfig.LeashItem) {
            String msg;
            if (wolf.getHealth() > wolf.HealthMax / 3 * 2) {
              msg="String_Node_Str" + ChatColor.GREEN + wolf.getHealth()+ ChatColor.WHITE+ "String_Node_Str"+ ChatColor.YELLOW+ wolf.HealthMax+ ChatColor.WHITE;
            }
 else             if (wolf.getHealth() > wolf.HealthMax / 3 * 1) {
              msg="String_Node_Str" + ChatColor.YELLOW + wolf.getHealth()+ ChatColor.WHITE+ "String_Node_Str"+ ChatColor.YELLOW+ wolf.HealthMax+ ChatColor.WHITE;
            }
 else {
              msg="String_Node_Str" + ChatColor.RED + wolf.getHealth()+ ChatColor.WHITE+ "String_Node_Str"+ ChatColor.YELLOW+ wolf.HealthMax+ ChatColor.WHITE;
            }
            player.sendMessage(MyWolfUtil.SetColors("String_Node_Str").replace("String_Node_Str",wolf.Name).replace("String_Node_Str",msg));
            player.sendMessage(MyWolfUtil.SetColors("String_Node_Str").replace("String_Node_Str",wolf.Name).replace("String_Node_Str",String.format("String_Node_Str",wolf.Experience.getExp())).replace("String_Node_Str","String_Node_Str" + wolf.Experience.getLevel()).replace("String_Node_Str",String.format("String_Node_Str",wolf.Experience.getrequireEXP())).replace("String_Node_Str",String.format("String_Node_Str",wolf.Experience.getExp() * 100 / wolf.Experience.getrequireEXP())));
            if (wolf.Wolf.isSitting()) {
              event.setCancelled(true);
              wolf.Wolf.setSitting(true);
            }
 else {
              event.setCancelled(true);
            }
          }
        }
        for (        Wolves wolf : ConfigBuffer.mWolves.values()) {
          if (wolf.getID() == event.getEntity().getEntityId()) {
            wolf.ResetSitTimer();
            if (wolf.getHealth() > wolf.HealthMax) {
              wolf.setHealth(wolf.HealthMax);
            }
            if (event.getDamage() < wolf.getHealth()) {
              wolf.setHealth(wolf.getHealth() + event.getDamage());
              wolf.Demage(event.getDamage());
            }
            if (event.isCancelled() == false && MyWolfUtil.getPVP(event.getEntity().getLocation()) == false) {
              event.setCancelled(true);
            }
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
public void onEntityDamage(final EntityDamageEvent event){
  if (event.getEntity() instanceof Wolf) {
    if (!(event instanceof EntityDamageByEntityEvent)) {
      return;
    }
    EntityDamageByEntityEvent e=(EntityDamageByEntityEvent)event;
    if (e.getDamager() instanceof Player) {
      Player player=(Player)e.getDamager();
      if (event.isCancelled() == false) {
        if (ConfigBuffer.mWolves.containsKey(player.getName()) == false) {
          if (MyWolfPermissions.has(player,"String_Node_Str") == false || player.getItemInHand().getType() != MyWolfConfig.LeashItem) {
            return;
          }
          Wolf TargetWolf=(Wolf)event.getEntity();
          String OwnerOfTheWolf=((CraftWolf)TargetWolf).getHandle().getOwnerName();
          Player Attacker=(Player)e.getDamager();
          boolean isTarmed=TargetWolf.isTamed();
          if (isTarmed == true && OwnerOfTheWolf.equals(Attacker.getName())) {
            event.setCancelled(true);
            ConfigBuffer.mWolves.put(player.getName(),new Wolves(player.getName()));
            ConfigBuffer.mWolves.get(player.getName()).createWolf((Wolf)event.getEntity());
            MyWolf.Plugin.SaveWolves(ConfigBuffer.WolvesConfig);
            player.sendMessage(MyWolfUtil.SetColors(MyWolfLanguage.getString("String_Node_Str")));
          }
        }
        String WolfOwner=null;
        for (        String owner : ConfigBuffer.mWolves.keySet()) {
          if (ConfigBuffer.mWolves.get(owner).getID() == event.getEntity().getEntityId()) {
            WolfOwner=owner;
            break;
          }
        }
        if (WolfOwner != null && WolfOwner.equals(player.getName())) {
          Wolves wolf=ConfigBuffer.mWolves.get(WolfOwner);
          wolf.ResetSitTimer();
          wolf.SetName();
          if (player.getItemInHand().getType() == MyWolfConfig.LeashItem) {
            String msg;
            if (wolf.getHealth() > wolf.HealthMax / 3 * 2) {
              msg="String_Node_Str" + ChatColor.GREEN + wolf.getHealth()+ ChatColor.WHITE+ "String_Node_Str"+ ChatColor.YELLOW+ wolf.HealthMax+ ChatColor.WHITE;
            }
 else             if (wolf.getHealth() > wolf.HealthMax / 3 * 1) {
              msg="String_Node_Str" + ChatColor.YELLOW + wolf.getHealth()+ ChatColor.WHITE+ "String_Node_Str"+ ChatColor.YELLOW+ wolf.HealthMax+ ChatColor.WHITE;
            }
 else {
              msg="String_Node_Str" + ChatColor.RED + wolf.getHealth()+ ChatColor.WHITE+ "String_Node_Str"+ ChatColor.YELLOW+ wolf.HealthMax+ ChatColor.WHITE;
            }
            player.sendMessage(MyWolfUtil.SetColors("String_Node_Str").replace("String_Node_Str",wolf.Name).replace("String_Node_Str",msg));
            player.sendMessage(MyWolfUtil.SetColors("String_Node_Str").replace("String_Node_Str",wolf.Name).replace("String_Node_Str",String.format("String_Node_Str",wolf.Experience.getExp())).replace("String_Node_Str","String_Node_Str" + wolf.Experience.getLevel()).replace("String_Node_Str",String.format("String_Node_Str",wolf.Experience.getrequireEXP())).replace("String_Node_Str",String.format("String_Node_Str",wolf.Experience.getExp() * 100 / wolf.Experience.getrequireEXP())));
            if (wolf.Wolf.isSitting()) {
              event.setCancelled(true);
              wolf.Wolf.setSitting(true);
            }
 else {
              event.setCancelled(true);
            }
          }
        }
        for (        Wolves wolf : ConfigBuffer.mWolves.values()) {
          if (wolf.getID() == event.getEntity().getEntityId()) {
            wolf.ResetSitTimer();
            if (wolf.getHealth() > wolf.HealthMax) {
              wolf.setHealth(wolf.HealthMax);
            }
            if (event.getDamage() < wolf.getHealth()) {
              wolf.setHealth(wolf.getHealth() + event.getDamage());
              wolf.Demage(event.getDamage());
            }
            if (event.isCancelled() == false && MyWolfUtil.getPVP(event.getEntity().getLocation()) == false) {
              event.setCancelled(true);
            }
          }
        }
      }
    }
  }
}