use of org.bukkit.entity.Projectile in project EliteMobs by MagmaGuy.
the class AttackPush method attackPush.
@EventHandler
public void attackPush(EntityDamageByEntityEvent event) {
Entity damager = event.getDamager();
Entity damagee = event.getEntity();
if (damager.hasMetadata(powerMetadata)) {
int pushbackStrength = 2;
Vector pushbackDirection = damagee.getLocation().toVector().subtract(damager.getLocation().toVector());
Vector pushbackApplied = pushbackDirection.normalize().multiply(pushbackStrength);
damagee.setVelocity(pushbackApplied);
}
if (damager instanceof Projectile) {
if (ProjectileMetadataDetector.projectileMetadataDetector(((Projectile) damager), powerMetadata)) {
int pushbackStrength = 2;
Vector pushbackDirection = damagee.getLocation().toVector().subtract(damager.getLocation().toVector());
Vector pushbackApplied = pushbackDirection.normalize().multiply(pushbackStrength);
damagee.setVelocity(pushbackApplied);
}
}
}
use of org.bukkit.entity.Projectile in project EliteMobs by MagmaGuy.
the class AttackWeakness method attackWeakness.
@EventHandler
public void attackWeakness(EntityDamageByEntityEvent event) {
Entity damager = event.getDamager();
Entity damagee = event.getEntity();
if (damager.hasMetadata(powerMetadata)) {
if (damagee instanceof Player) {
Player player = (Player) damagee;
player.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, 20 * 3, 0));
}
} else if (damager instanceof Projectile && damagee instanceof Player) {
if (ProjectileMetadataDetector.projectileMetadataDetector((Projectile) damager, powerMetadata)) {
Player player = (Player) damagee;
player.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, 20 * 3, 0));
}
}
}
use of org.bukkit.entity.Projectile in project EliteMobs by MagmaGuy.
the class AttackWither method onHit.
@EventHandler
public void onHit(EntityDamageByEntityEvent event) {
Entity damager = event.getDamager();
Entity damagee = event.getEntity();
if (damager.hasMetadata(powerMetadata) && damagee instanceof LivingEntity) {
((LivingEntity) damagee).addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 50, 1));
}
if (damager instanceof Projectile) {
if (ProjectileMetadataDetector.projectileMetadataDetector((Projectile) damager, powerMetadata)) {
((LivingEntity) damagee).addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 50, 1));
}
}
}
use of org.bukkit.entity.Projectile in project AuthMeReloaded by AuthMe.
the class EntityListenerTest method shouldAllowProjectileLaunchFromAuthedHuman.
@Test
public void shouldAllowProjectileLaunchFromAuthedHuman() {
// given
Projectile projectile = mock(Projectile.class);
Player player = mock(Player.class);
given(projectile.getShooter()).willReturn(player);
ProjectileLaunchEvent event = mock(ProjectileLaunchEvent.class);
given(event.getEntity()).willReturn(projectile);
given(listenerService.shouldCancelEvent(player)).willReturn(false);
// when
listener.onProjectileLaunch(event);
// then
verify(listenerService).shouldCancelEvent(player);
verify(event, never()).setCancelled(anyBoolean());
}
use of org.bukkit.entity.Projectile in project AuthMeReloaded by AuthMe.
the class EntityListenerTest method shouldAllowProjectileLaunchFromNonHuman.
@Test
public void shouldAllowProjectileLaunchFromNonHuman() {
// given
Projectile projectile = mock(Projectile.class);
ProjectileSource source = mock(ProjectileSource.class);
given(projectile.getShooter()).willReturn(source);
ProjectileLaunchEvent event = mock(ProjectileLaunchEvent.class);
given(event.getEntity()).willReturn(projectile);
// when
listener.onProjectileLaunch(event);
// then
verifyZeroInteractions(listenerService);
verify(event, never()).setCancelled(anyBoolean());
}
Aggregations