Program: 34067
Project: 34067
Buggy source:
/** 
 * This method protects players from PVP if it is not allowed and from arrows fired by other players
 * @param e
 */
@EventHandler(priority=EventPriority.LOW,ignoreCancelled=true) public void onEntityDamage(final EntityDamageByEntityEvent e){
  if (debug) {
    plugin.getLogger().info(e.getEventName());
    plugin.getLogger().info(e.getDamager().toString());
  }
  if (!inWorld(e.getEntity())) {
    return;
  }
  if (!Settings.allowTNTDamage && e.getDamager().getType().equals(EntityType.PRIMED_TNT)) {
    e.setCancelled(true);
    return;
  }
  if (!Settings.allowCreeperDamage && e.getDamager().getType().equals(EntityType.CREEPER) && !(e.getEntity() instanceof Player)) {
    e.setCancelled(true);
    return;
  }
  if (e.getDamager() instanceof Player) {
    Player p=(Player)e.getDamager();
    if (p.isOp() || VaultHelper.checkPerm(p,Settings.PERMPREFIX + "String_Node_Str")) {
      return;
    }
  }
  if (e.getEntity() instanceof ItemFrame) {
    if (!Settings.allowSpawnBreakBlocks && plugin.getGrid().isAtSpawn(e.getEntity().getLocation())) {
      ((Player)e.getDamager()).sendMessage(ChatColor.RED + Locale.islandProtected);
      e.setCancelled(true);
      return;
    }
    if (Settings.allowBreakBlocks) {
      return;
    }
    if (e.getDamager() instanceof Player) {
      if (!plugin.getGrid().locationIsOnIsland((Player)e.getDamager(),e.getEntity().getLocation())) {
        ((Player)e.getDamager()).sendMessage(ChatColor.RED + Locale.islandProtected);
        e.setCancelled(true);
        return;
      }
    }
 else     if (e.getDamager() instanceof Projectile) {
      Projectile p=(Projectile)e.getDamager();
      if (p.getShooter() instanceof Player) {
        if (!plugin.getGrid().locationIsOnIsland((Player)p.getShooter(),e.getEntity().getLocation())) {
          ((Player)p.getShooter()).sendMessage(ChatColor.RED + Locale.islandProtected);
          e.setCancelled(true);
          return;
        }
      }
    }
 else     if ((e.getDamager() instanceof TNTPrimed) && !Settings.allowTNTDamage) {
      e.setCancelled(true);
      return;
    }
  }
  if (!(e.getDamager() instanceof Player) && !(e.getDamager() instanceof Projectile)) {
    return;
  }
  if (e.getDamager() instanceof Player) {
    if (!(e.getEntity() instanceof Player)) {
      Location targetLoc=e.getEntity().getLocation();
      if (e.getEntity() instanceof Monster || e.getEntity() instanceof Slime || e.getEntity() instanceof Squid) {
        if (plugin.getGrid().isAtSpawn(targetLoc)) {
          if (!Settings.allowSpawnMobKilling) {
            ((Player)e.getDamager()).sendMessage(ChatColor.RED + Locale.islandProtected);
            e.setCancelled(true);
            return;
          }
          return;
        }
        if (!plugin.getGrid().locationIsOnIsland((Player)e.getDamager(),e.getEntity().getLocation())) {
          if (!Settings.allowHurtMonsters) {
            ((Player)e.getDamager()).sendMessage(ChatColor.RED + Locale.islandProtected);
            e.setCancelled(true);
            return;
          }
        }
        return;
      }
      if (e.getEntity() instanceof Animals) {
        if (plugin.getGrid().isAtSpawn(e.getEntity().getLocation())) {
          if (!Settings.allowSpawnAnimalKilling) {
            ((Player)e.getDamager()).sendMessage(ChatColor.RED + Locale.islandProtected);
            e.setCancelled(true);
            return;
          }
          return;
        }
        if (!Settings.allowHurtMobs) {
          if (!plugin.getGrid().locationIsOnIsland((Player)e.getDamager(),e.getEntity().getLocation())) {
            ((Player)e.getDamager()).sendMessage(ChatColor.RED + Locale.islandProtected);
            e.setCancelled(true);
            return;
          }
        }
        return;
      }
switch (e.getEntityType()) {
case IRON_GOLEM:
case SNOWMAN:
case VILLAGER:
        if (!Settings.allowHurtMobs) {
          if (!plugin.getGrid().locationIsOnIsland((Player)e.getDamager(),e.getEntity().getLocation())) {
            ((Player)e.getDamager()).sendMessage(ChatColor.RED + Locale.islandProtected);
            e.setCancelled(true);
            return;
          }
        }
      break;
default :
    break;
}
return;
}
 else {
if (Settings.allowPvP) {
  return;
}
}
}
if (e.getDamager() instanceof Projectile) {
Projectile projectile=(Projectile)e.getDamager();
if (projectile.getShooter() instanceof Player) {
Player shooter=(Player)projectile.getShooter();
if (e.getEntity() instanceof Player) {
  if (!Settings.allowPvP) {
    ((Player)projectile.getShooter()).sendMessage(Locale.targetInNoPVPArea);
    e.setCancelled(true);
    return;
  }
}
 else {
  if (!(e.getEntity() instanceof Monster) && !(e.getEntity() instanceof Slime) && !(e.getEntity() instanceof Squid)) {
    if (!Settings.allowHurtMobs) {
      if (!plugin.getGrid().locationIsOnIsland((Player)projectile.getShooter(),e.getEntity().getLocation())) {
        shooter.sendMessage(ChatColor.RED + Locale.islandProtected);
        e.setCancelled(true);
        return;
      }
    }
    return;
  }
 else {
    if (!Settings.allowHurtMonsters) {
      if (!plugin.getGrid().locationIsOnIsland((Player)e.getDamager(),e.getEntity().getLocation())) {
        ((Player)e.getDamager()).sendMessage(ChatColor.RED + Locale.islandProtected);
        e.setCancelled(true);
        return;
      }
    }
  }
}
}
}
 else if (e.getDamager() instanceof Player) {
if (!Settings.allowPvP) {
((Player)e.getDamager()).sendMessage(Locale.targetInNoPVPArea);
e.setCancelled(true);
return;
}
}
return;
}

Fixed version (ground truth):
/** 
 * This method protects players from PVP if it is not allowed and from arrows fired by other players
 * @param e
 */
@EventHandler(priority=EventPriority.LOW,ignoreCancelled=true) public void onEntityDamage(final EntityDamageByEntityEvent e){
  if (debug) {
    plugin.getLogger().info(e.getEventName());
    plugin.getLogger().info(e.getDamager().toString());
  }
  if (!inWorld(e.getEntity())) {
    return;
  }
  if (!Settings.allowTNTDamage && e.getDamager().getType().equals(EntityType.PRIMED_TNT)) {
    e.setCancelled(true);
    return;
  }
  if (!Settings.allowCreeperDamage && e.getDamager().getType().equals(EntityType.CREEPER) && !(e.getEntity() instanceof Player)) {
    e.setCancelled(true);
    return;
  }
  if (e.getDamager() instanceof Player) {
    Player p=(Player)e.getDamager();
    if (p.isOp() || VaultHelper.checkPerm(p,Settings.PERMPREFIX + "String_Node_Str")) {
      return;
    }
  }
  if (e.getEntity() instanceof ItemFrame) {
    if (!Settings.allowSpawnBreakBlocks && plugin.getGrid().isAtSpawn(e.getEntity().getLocation())) {
      ((Player)e.getDamager()).sendMessage(ChatColor.RED + Locale.islandProtected);
      e.setCancelled(true);
      return;
    }
    if (Settings.allowBreakBlocks || (Settings.allowSpawnBreakBlocks && plugin.getGrid().isAtSpawn(e.getEntity().getLocation()))) {
      return;
    }
    if (e.getDamager() instanceof Player) {
      if (!plugin.getGrid().locationIsOnIsland((Player)e.getDamager(),e.getEntity().getLocation())) {
        ((Player)e.getDamager()).sendMessage(ChatColor.RED + Locale.islandProtected);
        e.setCancelled(true);
        return;
      }
    }
 else     if (e.getDamager() instanceof Projectile) {
      Projectile p=(Projectile)e.getDamager();
      if (p.getShooter() instanceof Player) {
        if (!plugin.getGrid().locationIsOnIsland((Player)p.getShooter(),e.getEntity().getLocation())) {
          ((Player)p.getShooter()).sendMessage(ChatColor.RED + Locale.islandProtected);
          e.setCancelled(true);
          return;
        }
      }
    }
 else     if ((e.getDamager() instanceof TNTPrimed) && !Settings.allowTNTDamage) {
      e.setCancelled(true);
      return;
    }
  }
  if (!(e.getDamager() instanceof Player) && !(e.getDamager() instanceof Projectile)) {
    return;
  }
  if (e.getDamager() instanceof Player) {
    if (!(e.getEntity() instanceof Player)) {
      Location targetLoc=e.getEntity().getLocation();
      if (e.getEntity() instanceof Monster || e.getEntity() instanceof Slime || e.getEntity() instanceof Squid) {
        if (plugin.getGrid().isAtSpawn(targetLoc)) {
          if (!Settings.allowSpawnMobKilling) {
            ((Player)e.getDamager()).sendMessage(ChatColor.RED + Locale.islandProtected);
            e.setCancelled(true);
            return;
          }
          return;
        }
        if (!plugin.getGrid().locationIsOnIsland((Player)e.getDamager(),e.getEntity().getLocation())) {
          if (!Settings.allowHurtMonsters) {
            ((Player)e.getDamager()).sendMessage(ChatColor.RED + Locale.islandProtected);
            e.setCancelled(true);
            return;
          }
        }
        return;
      }
      if (e.getEntity() instanceof Animals) {
        if (plugin.getGrid().isAtSpawn(e.getEntity().getLocation())) {
          if (!Settings.allowSpawnAnimalKilling) {
            ((Player)e.getDamager()).sendMessage(ChatColor.RED + Locale.islandProtected);
            e.setCancelled(true);
            return;
          }
          return;
        }
        if (!Settings.allowHurtMobs) {
          if (!plugin.getGrid().locationIsOnIsland((Player)e.getDamager(),e.getEntity().getLocation())) {
            ((Player)e.getDamager()).sendMessage(ChatColor.RED + Locale.islandProtected);
            e.setCancelled(true);
            return;
          }
        }
        return;
      }
switch (e.getEntityType()) {
case IRON_GOLEM:
case SNOWMAN:
case VILLAGER:
        if (!Settings.allowHurtMobs) {
          if (!plugin.getGrid().locationIsOnIsland((Player)e.getDamager(),e.getEntity().getLocation())) {
            ((Player)e.getDamager()).sendMessage(ChatColor.RED + Locale.islandProtected);
            e.setCancelled(true);
            return;
          }
        }
      break;
default :
    break;
}
return;
}
 else {
if (Settings.allowPvP) {
  return;
}
}
}
if (e.getDamager() instanceof Projectile) {
Projectile projectile=(Projectile)e.getDamager();
if (projectile.getShooter() instanceof Player) {
Player shooter=(Player)projectile.getShooter();
if (e.getEntity() instanceof Player) {
  if (!Settings.allowPvP) {
    ((Player)projectile.getShooter()).sendMessage(Locale.targetInNoPVPArea);
    e.setCancelled(true);
    return;
  }
}
 else {
  if (!(e.getEntity() instanceof Monster) && !(e.getEntity() instanceof Slime) && !(e.getEntity() instanceof Squid)) {
    if (!Settings.allowHurtMobs) {
      if (!plugin.getGrid().locationIsOnIsland((Player)projectile.getShooter(),e.getEntity().getLocation())) {
        shooter.sendMessage(ChatColor.RED + Locale.islandProtected);
        e.setCancelled(true);
        return;
      }
    }
    return;
  }
 else {
    if (!Settings.allowHurtMonsters) {
      if (!plugin.getGrid().locationIsOnIsland((Player)e.getDamager(),e.getEntity().getLocation())) {
        ((Player)e.getDamager()).sendMessage(ChatColor.RED + Locale.islandProtected);
        e.setCancelled(true);
        return;
      }
    }
  }
}
}
}
 else if (e.getDamager() instanceof Player) {
if (!Settings.allowPvP) {
((Player)e.getDamager()).sendMessage(Locale.targetInNoPVPArea);
e.setCancelled(true);
return;
}
}
return;
}