Program: 187728
Project: 187728
Buggy source:
@Override 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 (cb.mWolves.containsKey(player.getName()) == false) {
          if (cb.Permissions != null && cb.Permissions.has(player,"String_Node_Str") == false) {
            return;
          }
          if (((Wolf)event.getEntity()).isTamed() == true && ((Player)((Wolf)event.getEntity()).getOwner()).getName().equals(player.getName())) {
            event.setCancelled(true);
            cb.mWolves.put(player.getName(),new Wolves(cb,player.getName()));
            cb.mWolves.get(player.getName()).createWolf((Wolf)event.getEntity());
            cb.Plugin.SaveWolves();
            player.sendMessage(ChatColor.GREEN + "String_Node_Str");
          }
        }
        for (        String owner : cb.mWolves.keySet()) {
          Wolves wolf=cb.mWolves.get(owner);
          if (wolf.getID() == event.getEntity().getEntityId()) {
            if (cb.mWolves.get(owner).getHealth() > cb.mWolves.get(owner).HealthMax) {
              cb.mWolves.get(owner).setWolfHealth(cb.mWolves.get(owner).HealthMax);
            }
            if (player.getItemInHand().getType() == cb.cv.WolfLeashItem && cb.cv.WolfLeashItemSneak == player.isSneaking()) {
              if (cb.Permissions != null && cb.Permissions.has(player,"String_Node_Str") == false) {
                return;
              }
{
                String msg="String_Node_Str" + ChatColor.GREEN;
                if (wolf.Name != null) {
                  msg+=wolf.Name + ChatColor.WHITE + "String_Node_Str";
                }
 else {
                  msg+="String_Node_Str" + ChatColor.WHITE + "String_Node_Str";
                }
                if (wolf.getHealth() > wolf.HealthMax / 3 * 2) {
                  msg+="String_Node_Str" + ChatColor.GREEN + wolf.getHealth()+ ChatColor.WHITE+ "String_Node_Str"+ ChatColor.YELLOW+ wolf.HealthMax;
                }
 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;
                }
 else {
                  msg+="String_Node_Str" + ChatColor.RED + wolf.getHealth()+ ChatColor.WHITE+ "String_Node_Str"+ ChatColor.YELLOW+ wolf.HealthMax;
                }
                player.sendMessage(msg);
                if (wolf.MyWolf.isSitting()) {
                  event.setCancelled(true);
                  wolf.isSitting=true;
                  wolf.MyWolf.setSitting(true);
                }
 else {
                  wolf.isSitting=false;
                  event.setCancelled(true);
                }
              }
            }
            if (player.getItemInHand().getType() == cb.cv.WolfChestAddItem) {
              if (wolf.MyWolf.getEntityId() == event.getEntity().getEntityId()) {
                if (cb.Permissions != null && cb.Permissions.has(player,"String_Node_Str") == false) {
                  return;
                }
                if (wolf.hasInventory == false) {
                  wolf.hasInventory=true;
                  if (player.getItemInHand().getAmount() > 1) {
                    player.getItemInHand().setAmount(player.getItemInHand().getAmount() - 1);
                  }
 else {
                    player.getInventory().removeItem(player.getInventory().getItemInHand());
                  }
                  event.setCancelled(true);
                  wolf.MyWolf.setSitting(true);
                  player.sendMessage(ChatColor.AQUA + wolf.Name + ChatColor.WHITE+ "String_Node_Str");
                }
              }
            }
            if (player.getItemInHand().getType() == cb.cv.WolfFoodLivesItem) {
              if (cb.cv.WolfMaxLives > -1 && wolf.MyWolf.getEntityId() == event.getEntity().getEntityId()) {
                if (cb.Permissions != null && cb.Permissions.has(player,"String_Node_Str") == false) {
                  return;
                }
                if (wolf.Lives < cb.cv.WolfMaxLives) {
                  wolf.Lives+=1;
                  if (player.getItemInHand().getAmount() > 1) {
                    player.getItemInHand().setAmount(player.getItemInHand().getAmount() - 1);
                  }
 else {
                    player.getInventory().removeItem(player.getInventory().getItemInHand());
                  }
                  player.sendMessage(ChatColor.GREEN + "String_Node_Str" + ChatColor.AQUA+ wolf.Name);
                }
 else {
                  player.sendMessage(ChatColor.AQUA + wolf.Name + ChatColor.RED+ "String_Node_Str"+ cb.cv.WolfMaxLives+ "String_Node_Str");
                }
                if (wolf.MyWolf.isSitting()) {
                  wolf.isSitting=true;
                  wolf.MyWolf.setSitting(true);
                }
 else {
                  wolf.isSitting=false;
                }
                event.setCancelled(true);
              }
            }
            if (player.getItemInHand().getType() == cb.cv.WolfPickupItem) {
              if (wolf.MyWolf.getEntityId() == event.getEntity().getEntityId()) {
                if (cb.Permissions != null && cb.Permissions.has(player,"String_Node_Str") == false) {
                  return;
                }
                if (wolf.hasPickup == false) {
                  wolf.hasPickup=true;
                  if (player.getItemInHand().getAmount() > 1) {
                    player.getItemInHand().setAmount(player.getItemInHand().getAmount() - 1);
                  }
 else {
                    player.getInventory().removeItem(player.getInventory().getItemInHand());
                  }
                  event.setCancelled(true);
                  wolf.MyWolf.setSitting(true);
                  wolf.DropTimer();
                  player.sendMessage(ChatColor.AQUA + wolf.Name + ChatColor.WHITE+ "String_Node_Str"+ cb.cv.WolfPickupRange+ "String_Node_Str");
                }
              }
            }
            if (player.getItemInHand().getType() == cb.cv.WolfChestOpenItem && cb.cv.WolfChestOpenItemSneak == player.isSneaking()) {
              if (wolf.MyWolf.getEntityId() == event.getEntity().getEntityId()) {
                if (cb.Permissions != null && cb.Permissions.has(player,"String_Node_Str") == false) {
                  return;
                }
                if (wolf.hasInventory == true) {
                  EntityPlayer eh=((CraftPlayer)player).getHandle();
                  eh.a(wolf.Inventory);
                  event.setCancelled(true);
                  wolf.MyWolf.setSitting(true);
                }
              }
            }
            if (player.getItemInHand().getType() == cb.cv.WolfFoodHPItem) {
              if (wolf.MyWolf.getEntityId() == event.getEntity().getEntityId()) {
                if (cb.Permissions != null && cb.Permissions.has(player,"String_Node_Str") == false) {
                  return;
                }
                if (wolf.HealthMax < cb.cv.WolfRespawnMaxHP) {
                  String msg="String_Node_Str" + ChatColor.AQUA + wolf.Name+ ChatColor.WHITE+ "String_Node_Str";
                  wolf.HealthMax+=1;
                  wolf.setWolfHealth(wolf.getHealth() + 1);
                  if (player.getItemInHand().getAmount() > 1) {
                    player.getItemInHand().setAmount(player.getItemInHand().getAmount() - 1);
                  }
 else {
                    player.getInventory().removeItem(player.getInventory().getItemInHand());
                  }
                  if (wolf.getHealth() > wolf.HealthMax / 3 * 2) {
                    msg+="String_Node_Str" + ChatColor.GREEN + wolf.getHealth()+ ChatColor.WHITE+ "String_Node_Str"+ ChatColor.YELLOW+ wolf.HealthMax;
                  }
 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;
                  }
 else {
                    msg+="String_Node_Str" + ChatColor.RED + wolf.getHealth()+ ChatColor.WHITE+ "String_Node_Str"+ ChatColor.YELLOW+ wolf.HealthMax;
                  }
                  player.sendMessage(ChatColor.GREEN + "String_Node_Str" + ChatColor.AQUA+ wolf.Name);
                  player.sendMessage(msg);
                }
 else {
                  player.sendMessage(ChatColor.AQUA + wolf.Name + ChatColor.RED+ "String_Node_Str"+ cb.cv.WolfRespawnMaxHP+ "String_Node_Str");
                }
                if (wolf.MyWolf.isSitting()) {
                  wolf.isSitting=true;
                  wolf.MyWolf.setSitting(true);
                }
 else {
                  wolf.isSitting=false;
                }
                event.setCancelled(true);
              }
            }
            if (event.isCancelled() == false && event.getEntity().getWorld().getPVP() == false) {
              event.setCancelled(true);
            }
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
@Override 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 (cb.mWolves.containsKey(player.getName()) == false) {
          if (cb.Permissions.has(player,"String_Node_Str") == false || player.getItemInHand().getType() != cb.cv.WolfLeashItem) {
            return;
          }
          Wolf TargetWolf=(Wolf)event.getEntity();
          String OwnerOfTheWolf=((CraftWolf)TargetWolf).getHandle().x();
          Player Attacker=(Player)e.getDamager();
          boolean isTarmed=TargetWolf.isTamed();
          if (isTarmed == true && OwnerOfTheWolf.equals(Attacker.getName())) {
            event.setCancelled(true);
            cb.mWolves.put(player.getName(),new Wolves(cb,player.getName()));
            cb.mWolves.get(player.getName()).createWolf((Wolf)event.getEntity());
            cb.Plugin.SaveWolves();
            player.sendMessage(ChatColor.GREEN + "String_Node_Str");
          }
        }
        for (        String owner : cb.mWolves.keySet()) {
          Wolves wolf=cb.mWolves.get(owner);
          if (wolf.getID() == event.getEntity().getEntityId()) {
            if (cb.mWolves.get(owner).getHealth() > cb.mWolves.get(owner).HealthMax) {
              cb.mWolves.get(owner).setWolfHealth(cb.mWolves.get(owner).HealthMax);
            }
            if (player.getItemInHand().getType() == cb.cv.WolfLeashItem && cb.cv.WolfLeashItemSneak == player.isSneaking()) {
              if (cb.Permissions != null && cb.Permissions.has(player,"String_Node_Str") == false) {
                return;
              }
{
                String msg="String_Node_Str" + ChatColor.GREEN;
                if (wolf.Name != null) {
                  msg+=wolf.Name + ChatColor.WHITE + "String_Node_Str";
                }
 else {
                  msg+="String_Node_Str" + ChatColor.WHITE + "String_Node_Str";
                }
                if (wolf.getHealth() > wolf.HealthMax / 3 * 2) {
                  msg+="String_Node_Str" + ChatColor.GREEN + wolf.getHealth()+ ChatColor.WHITE+ "String_Node_Str"+ ChatColor.YELLOW+ wolf.HealthMax;
                }
 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;
                }
 else {
                  msg+="String_Node_Str" + ChatColor.RED + wolf.getHealth()+ ChatColor.WHITE+ "String_Node_Str"+ ChatColor.YELLOW+ wolf.HealthMax;
                }
                player.sendMessage(msg);
                if (wolf.MyWolf.isSitting()) {
                  event.setCancelled(true);
                  wolf.isSitting=true;
                  wolf.MyWolf.setSitting(true);
                }
 else {
                  wolf.isSitting=false;
                  event.setCancelled(true);
                }
              }
            }
            if (player.getItemInHand().getType() == cb.cv.WolfChestAddItem) {
              if (wolf.MyWolf.getEntityId() == event.getEntity().getEntityId()) {
                if (cb.Permissions != null && cb.Permissions.has(player,"String_Node_Str") == false) {
                  return;
                }
                if (wolf.hasInventory == false) {
                  wolf.hasInventory=true;
                  if (player.getItemInHand().getAmount() > 1) {
                    player.getItemInHand().setAmount(player.getItemInHand().getAmount() - 1);
                  }
 else {
                    player.getInventory().removeItem(player.getInventory().getItemInHand());
                  }
                  event.setCancelled(true);
                  wolf.MyWolf.setSitting(true);
                  player.sendMessage(ChatColor.AQUA + wolf.Name + ChatColor.WHITE+ "String_Node_Str");
                }
              }
            }
            if (player.getItemInHand().getType() == cb.cv.WolfFoodLivesItem) {
              if (cb.cv.WolfMaxLives > -1 && wolf.MyWolf.getEntityId() == event.getEntity().getEntityId()) {
                if (cb.Permissions != null && cb.Permissions.has(player,"String_Node_Str") == false) {
                  return;
                }
                if (wolf.Lives < cb.cv.WolfMaxLives) {
                  wolf.Lives+=1;
                  if (player.getItemInHand().getAmount() > 1) {
                    player.getItemInHand().setAmount(player.getItemInHand().getAmount() - 1);
                  }
 else {
                    player.getInventory().removeItem(player.getInventory().getItemInHand());
                  }
                  player.sendMessage(ChatColor.GREEN + "String_Node_Str" + ChatColor.AQUA+ wolf.Name);
                }
 else {
                  player.sendMessage(ChatColor.AQUA + wolf.Name + ChatColor.RED+ "String_Node_Str"+ cb.cv.WolfMaxLives+ "String_Node_Str");
                }
                if (wolf.MyWolf.isSitting()) {
                  wolf.isSitting=true;
                  wolf.MyWolf.setSitting(true);
                }
 else {
                  wolf.isSitting=false;
                }
                event.setCancelled(true);
              }
            }
            if (player.getItemInHand().getType() == cb.cv.WolfPickupItem) {
              if (wolf.MyWolf.getEntityId() == event.getEntity().getEntityId()) {
                if (cb.Permissions != null && cb.Permissions.has(player,"String_Node_Str") == false) {
                  return;
                }
                if (wolf.hasPickup == false) {
                  wolf.hasPickup=true;
                  if (player.getItemInHand().getAmount() > 1) {
                    player.getItemInHand().setAmount(player.getItemInHand().getAmount() - 1);
                  }
 else {
                    player.getInventory().removeItem(player.getInventory().getItemInHand());
                  }
                  event.setCancelled(true);
                  wolf.MyWolf.setSitting(true);
                  wolf.DropTimer();
                  player.sendMessage(ChatColor.AQUA + wolf.Name + ChatColor.WHITE+ "String_Node_Str"+ cb.cv.WolfPickupRange+ "String_Node_Str");
                }
              }
            }
            if (player.getItemInHand().getType() == cb.cv.WolfChestOpenItem && cb.cv.WolfChestOpenItemSneak == player.isSneaking()) {
              if (wolf.MyWolf.getEntityId() == event.getEntity().getEntityId()) {
                if (cb.Permissions != null && cb.Permissions.has(player,"String_Node_Str") == false) {
                  return;
                }
                if (wolf.hasInventory == true) {
                  EntityPlayer eh=((CraftPlayer)player).getHandle();
                  eh.a(wolf.Inventory);
                  event.setCancelled(true);
                  wolf.MyWolf.setSitting(true);
                }
              }
            }
            if (player.getItemInHand().getType() == cb.cv.WolfFoodHPItem) {
              if (wolf.MyWolf.getEntityId() == event.getEntity().getEntityId()) {
                if (cb.Permissions != null && cb.Permissions.has(player,"String_Node_Str") == false) {
                  return;
                }
                if (wolf.HealthMax < cb.cv.WolfRespawnMaxHP) {
                  String msg="String_Node_Str" + ChatColor.AQUA + wolf.Name+ ChatColor.WHITE+ "String_Node_Str";
                  wolf.HealthMax+=1;
                  wolf.setWolfHealth(wolf.getHealth() + 1);
                  if (player.getItemInHand().getAmount() > 1) {
                    player.getItemInHand().setAmount(player.getItemInHand().getAmount() - 1);
                  }
 else {
                    player.getInventory().removeItem(player.getInventory().getItemInHand());
                  }
                  if (wolf.getHealth() > wolf.HealthMax / 3 * 2) {
                    msg+="String_Node_Str" + ChatColor.GREEN + wolf.getHealth()+ ChatColor.WHITE+ "String_Node_Str"+ ChatColor.YELLOW+ wolf.HealthMax;
                  }
 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;
                  }
 else {
                    msg+="String_Node_Str" + ChatColor.RED + wolf.getHealth()+ ChatColor.WHITE+ "String_Node_Str"+ ChatColor.YELLOW+ wolf.HealthMax;
                  }
                  player.sendMessage(ChatColor.GREEN + "String_Node_Str" + ChatColor.AQUA+ wolf.Name);
                  player.sendMessage(msg);
                }
 else {
                  player.sendMessage(ChatColor.AQUA + wolf.Name + ChatColor.RED+ "String_Node_Str"+ cb.cv.WolfRespawnMaxHP+ "String_Node_Str");
                }
                if (wolf.MyWolf.isSitting()) {
                  wolf.isSitting=true;
                  wolf.MyWolf.setSitting(true);
                }
 else {
                  wolf.isSitting=false;
                }
                event.setCancelled(true);
              }
            }
            if (event.isCancelled() == false && event.getEntity().getWorld().getPVP() == false) {
              event.setCancelled(true);
            }
          }
        }
      }
    }
  }
}