use of org.bukkit.entity.Projectile in project EliteMobs by MagmaGuy.
the class AttackFire method attackFire.
@EventHandler
public void attackFire(EntityDamageByEntityEvent event) {
Entity damager = event.getDamager();
Entity damagee = event.getEntity();
if (damager.hasMetadata(powerMetadata)) {
damagee.setFireTicks(40);
}
if (damager instanceof Projectile) {
if (ProjectileMetadataDetector.projectileMetadataDetector((Projectile) damager, powerMetadata)) {
damagee.setFireTicks(40);
}
}
}
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 RedProtect by FabioZumbi12.
the class RPEntityListener method entityFire.
@EventHandler(priority = EventPriority.HIGHEST)
public void entityFire(EntityCombustByEntityEvent e) {
Entity e1 = e.getEntity();
Entity e2 = e.getCombuster();
if (e2 == null) {
return;
}
RedProtect.get().logger.debug("EntityCombustByEntityEvent - Is EntityCombustByEntityEvent event.");
if (e2 instanceof Projectile) {
Projectile a = (Projectile) e2;
if (a.getShooter() instanceof Entity) {
e2 = (Entity) a.getShooter();
}
a = null;
if (e2 == null) {
return;
}
}
Region r1 = RedProtect.get().rm.getTopRegion(e1.getLocation());
Region r2 = RedProtect.get().rm.getTopRegion(e2.getLocation());
if (r1 != null && !r1.canFire() && !(e2 instanceof Player)) {
e.setCancelled(true);
return;
}
if (e1 instanceof Player) {
if (e2 instanceof Player && !e1.equals(e2)) {
Player p2 = (Player) e2;
if (r1 != null) {
if (r2 != null) {
if ((r1.flagExists("pvp") && !r1.canPVP((Player) e1, p2)) || (r1.flagExists("pvp") && !r2.canPVP((Player) e1, p2))) {
e.setCancelled(true);
RPLang.sendMessage(p2, "entitylistener.region.cantpvp");
}
} else if (r1.flagExists("pvp") && !r1.canPVP((Player) e1, p2)) {
e.setCancelled(true);
RPLang.sendMessage(p2, "entitylistener.region.cantpvp");
}
} else if (r2 != null && r2.flagExists("pvp") && !r2.canPVP((Player) e1, p2)) {
e.setCancelled(true);
RPLang.sendMessage(p2, "entitylistener.region.cantpvp");
}
}
} else if (e1 instanceof Animals || e1 instanceof Villager || e1 instanceof Golem) {
if (r1 != null && e2 instanceof Player) {
Player p2 = (Player) e2;
if (!r1.canInteractPassives(p2)) {
e.setCancelled(true);
RPLang.sendMessage(p2, "entitylistener.region.cantpassive");
}
}
} else if (e1 instanceof Hanging && e2 instanceof Player) {
Player p2 = (Player) e2;
if (r1 != null && !r1.canBuild(p2) && !r1.canBreak(e1.getType())) {
e.setCancelled(true);
RPLang.sendMessage(p2, "playerlistener.region.cantuse");
return;
}
if (r2 != null && !r2.canBuild(p2) && !r2.canBreak(e1.getType())) {
e.setCancelled(true);
RPLang.sendMessage(p2, "playerlistener.region.cantuse");
}
} else if (e1 instanceof Hanging && e2 instanceof Monster) {
if (r1 != null || r2 != null) {
RedProtect.get().logger.debug("Cancelled ItemFrame drop Item");
e.setCancelled(true);
}
} else if (e2 instanceof Explosive) {
if ((r1 != null && !r1.canFire()) || (r2 != null && !r2.canFire())) {
e.setCancelled(true);
}
}
}
Aggregations