{
if (sub.getEntity() instanceof Wolf && sub.getDamager() instanceof Player)
{
attacker = (Player) sub.getDamager();
Wolf wolf = (Wolf) sub.getEntity();
ClanPlayer cp = plugin.getClanManager().getClanPlayer(attacker);
if (wolf.isTamed())
{
if (cp.getClan().isMember((Player) wolf.getOwner()))
{
// Sets the wolf to friendly if the attacker is one out of his clan
wolf.setAngry(false);
}
}
}
}
if (sub.getEntity() instanceof Player && sub.getDamager() instanceof Arrow)
{
Arrow arrow = (Arrow) sub.getDamager();
if (arrow.getShooter() instanceof Player)
{
attacker = (Player) arrow.getShooter();
victim = (Player) sub.getEntity();
}
}
}
if (victim != null)
{
if (plugin.getSettingsManager().isBlacklistedWorld(victim.getLocation().getWorld().getName()))
{
return;
}
}
if (attacker != null && victim != null)
{
ClanPlayer acp = plugin.getClanManager().getClanPlayer(attacker);
ClanPlayer vcp = plugin.getClanManager().getClanPlayer(victim);
Clan vclan = vcp == null ? null : vcp.getClan();
Clan aclan = acp == null ? null : acp.getClan();
if (plugin.getSettingsManager().isPvpOnlywhileInWar())
{
// if one doesn't have clan then they cant be at war
if (aclan == null || vclan == null)
{
event.setCancelled(true);
return;
}
if (plugin.getPermissionsManager().has(victim, "simpleclans.mod.nopvpinwar")
&& attacker != null && victim != null)
{
event.setCancelled(true);
return;
}
// if not warring no pvp
if (!aclan.isWarring(vclan))
{
event.setCancelled(true);
return;
}
}
if (vclan != null)
{
if (aclan != null)
{
// personal ff enabled, allow damage
if (vcp.isFriendlyFire())
{
return;
}
// clan ff enabled, allow damage