Don't apply attributes on friendlies. Fixes PC-369
This commit is contained in:
parent
9af2c7e9f4
commit
2680c2b244
@ -1,8 +1,12 @@
|
|||||||
package mineplex.game.clans.items.attributes;
|
package mineplex.game.clans.items.attributes;
|
||||||
|
|
||||||
|
import mineplex.game.clans.clans.ClansManager;
|
||||||
|
import mineplex.game.clans.clans.ClansUtility;
|
||||||
import mineplex.game.clans.items.generation.ValueDistribution;
|
import mineplex.game.clans.items.generation.ValueDistribution;
|
||||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
|
||||||
@ -127,4 +131,21 @@ public abstract class ItemAttribute
|
|||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean isTeammate(Entity attacker, Entity defender)
|
||||||
|
{
|
||||||
|
if (attacker == null || defender == null) return false;
|
||||||
|
// Don't count attacks towards teammates
|
||||||
|
if (attacker instanceof Player && defender instanceof Player)
|
||||||
|
{
|
||||||
|
ClansUtility.ClanRelation relation = ClansManager.getInstance().getRelation((Player) attacker, (Player) defender);
|
||||||
|
if (relation == ClansUtility.ClanRelation.ALLY
|
||||||
|
|| relation == ClansUtility.ClanRelation.SAFE
|
||||||
|
|| relation == ClansUtility.ClanRelation.SELF)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,7 @@ public class FlamingAttribute extends AttackAttribute
|
|||||||
if(attacker instanceof Player && ClansManager.getInstance().isSafe((Player) attacker)) return;
|
if(attacker instanceof Player && ClansManager.getInstance().isSafe((Player) attacker)) return;
|
||||||
if(defender instanceof Player && ClansManager.getInstance().isSafe((Player) defender)) return;
|
if(defender instanceof Player && ClansManager.getInstance().isSafe((Player) defender)) return;
|
||||||
if(attacker instanceof Player && ((Player)attacker).getGameMode().equals(GameMode.CREATIVE)) return;
|
if(attacker instanceof Player && ((Player)attacker).getGameMode().equals(GameMode.CREATIVE)) return;
|
||||||
|
if (isTeammate(attacker, defender)) return;
|
||||||
defender.setFireTicks(_fireDuration);
|
defender.setFireTicks(_fireDuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,6 +54,7 @@ public class FrostedAttribute extends ItemAttribute
|
|||||||
|
|
||||||
if (victim != null)
|
if (victim != null)
|
||||||
{
|
{
|
||||||
|
if (isTeammate(event.GetDamagerPlayer(true), victim)) return;
|
||||||
victim.addPotionEffect(generateSlowEffect()); // Slow attacking player
|
victim.addPotionEffect(generateSlowEffect()); // Slow attacking player
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,7 @@ public class HasteAttribute extends AttackAttribute
|
|||||||
@Override
|
@Override
|
||||||
public void triggerAttack(Entity attacker, Entity defender)
|
public void triggerAttack(Entity attacker, Entity defender)
|
||||||
{
|
{
|
||||||
|
if (isTeammate(attacker, defender)) return;
|
||||||
if (attacker instanceof Player)
|
if (attacker instanceof Player)
|
||||||
{
|
{
|
||||||
Player player = (Player) attacker;
|
Player player = (Player) attacker;
|
||||||
|
@ -28,6 +28,7 @@ public class JaggedAttribute extends AttackAttribute {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void triggerAttack(Entity attacker, Entity defender) {
|
public void triggerAttack(Entity attacker, Entity defender) {
|
||||||
|
if (isTeammate(attacker, defender)) return;
|
||||||
defender.setVelocity(new Vector(0, 0, 0));
|
defender.setVelocity(new Vector(0, 0, 0));
|
||||||
if (defender instanceof LivingEntity)
|
if (defender instanceof LivingEntity)
|
||||||
((LivingEntity) defender).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 20, 1, false, false));
|
((LivingEntity) defender).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 20, 1, false, false));
|
||||||
|
@ -38,6 +38,8 @@ public class VampiricAttribute extends ItemAttribute
|
|||||||
{
|
{
|
||||||
Player damager = event.GetDamagerPlayer(false);
|
Player damager = event.GetDamagerPlayer(false);
|
||||||
|
|
||||||
|
if (isTeammate(damager, event.GetDamageePlayer())) return;
|
||||||
|
|
||||||
double damage = event.GetDamage();
|
double damage = event.GetDamage();
|
||||||
double healAmount = damage * (_healPercent / 100d);
|
double healAmount = damage * (_healPercent / 100d);
|
||||||
heal(damager, healAmount);
|
heal(damager, healAmount);
|
||||||
|
Loading…
Reference in New Issue
Block a user